Skip to content

Commit 6b047be

Browse files
committed
Initial commit for GitHub
0 parents  commit 6b047be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+17597
-0
lines changed

.clang-tidy

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
Checks: 'performance-*,
16+
cppcoreguidelines-*,
17+
readability-*,
18+
modernize-*,
19+
bugprone-*,
20+
-cppcoreguidelines-macro-usage,
21+
-cppcoreguidelines-avoid-magic-numbers,
22+
-readability-magic-numbers,
23+
-readability-function-cognitive-complexity,
24+
-readability-identifier-length'
25+
WarningsAsErrors: '*'

.github/workflows/check_format.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Check Format
16+
17+
on:
18+
push:
19+
branches: [main]
20+
pull_request:
21+
branches: [main]
22+
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Install Baseline
31+
run: |
32+
apt update
33+
apt install -y parallel
34+
35+
- name: Check format
36+
run: |
37+
bash scripts/check_format.sh --install

.github/workflows/cpp_linter.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Check Format
16+
17+
on:
18+
push:
19+
branches: [main]
20+
pull_request:
21+
branches: [main]
22+
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Install baseline
31+
run: |
32+
apt -y update
33+
apt -y upgrade
34+
apt -y install cmake \
35+
g++ \
36+
libmpfr-dev \
37+
python3-dev \
38+
python3-pybind11 \
39+
libboost-dev \
40+
libmpfr6 \
41+
parallel
42+
43+
- name: Build
44+
run: |
45+
cmake -B build/ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug
46+
47+
- name: Call linter
48+
run: |
49+
bash scripts/cpp_linter.sh --install --build build/

.github/workflows/run_tests.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Run Tests
16+
17+
on:
18+
push:
19+
branches: [main]
20+
pull_request:
21+
branches: [main]
22+
23+
jobs:
24+
build:
25+
strategy:
26+
fail-fast: true
27+
matrix:
28+
os: [ubuntu-latest]
29+
python-version: [3.8.x, 3.x]
30+
compiler: [g++, clang]
31+
target: [Debug]
32+
33+
runs-on: ${{ matrix.os }}
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
39+
- name: Set up Python ${{ matrix.python-version }}
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: ${{ matrix.python-version }}
43+
44+
- name: Install baseline for ${{ matrix.os }}, with ${{ matrix.compiler }}
45+
run: |
46+
apt -y update
47+
apt -y upgrade
48+
apt -y install cmake \
49+
${{ matrix.compiler }} \
50+
libmpfr-dev \
51+
python3-dev \
52+
libboost-dev \
53+
libmpfr6
54+
55+
- name: Install TNCO for ${{ matrix.os }}, with ${{ matrix.compiler }} and python==${{
56+
matrix.python-version }} (${{ matrix.target }})
57+
run: |
58+
if [[ ${{ matrix.compiler }} == g++ ]]; then
59+
export CC=gcc
60+
export CXX=g++
61+
elif [[ ${{ matrix.compiler }} == clang ]]; then
62+
export CC=clang
63+
export CXX=clang++
64+
else
65+
echo 'Not supported.'
66+
return 1
67+
fi
68+
pip install .[parallel,testing] --config-settings=cmake.build-type=${{ matrix.target }} --verbose
69+
70+
- name: Run Tests for ${{ matrix.os }}, with ${{ matrix.compiler }} and python==${{
71+
matrix.python-version }} (${{ matrix.target }})
72+
if: matrix.os == 'ubuntu-latest' && matrix.compiler == 'g++' && matrix.python-version
73+
== '3.x'
74+
run: |
75+
pip install pytest-sugar
76+
pytest --verbose --timeout=180 -n $((2 * $(nproc))) tests/*.py
77+
78+
- name: Run CLI for ${{ matrix.os }}, with ${{ matrix.compiler }} and python==${{
79+
matrix.python-version }} (${{ matrix.target }})
80+
run: |
81+
tnco optimize '2 a b' '(0, 100)' --n-steps=100 --n-runs=100 > /dev/null
82+
83+
- name: Run Example for ${{ matrix.os }}, with ${{ matrix.compiler }} and python==${{
84+
matrix.python-version }} (${{ matrix.target }})
85+
run: |
86+
pip install jupyterlab papermill
87+
papermill examples/Optimization.ipynb /dev/null

.gitignore

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Python cache
16+
__pycache__
17+
.ipynb_checkpoints
18+
19+
# Distribution / packaging
20+
.Python
21+
build/
22+
develop-eggs/
23+
dist/
24+
downloads/
25+
eggs/
26+
.eggs/
27+
lib/
28+
lib64/
29+
parts/
30+
sdist/
31+
var/
32+
wheels/
33+
share/python-wheels/
34+
*.egg-info/
35+
.installed.cfg
36+
*.egg
37+
MANIFEST
38+
39+
# Environments
40+
.env
41+
.venv
42+
env/
43+
venv/
44+
ENV/
45+
env.bak/
46+
venv.bak/
47+
venv-*/
48+
49+
# Swap files
50+
.*.swp
51+
52+
# Pipfile
53+
Pipfile
54+
55+
# Backup files
56+
__backup.*__
57+
58+
# Temp files
59+
__temp.*__

CMakeLists.txt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# Set the minimum required version for cmake
16+
cmake_minimum_required(VERSION 3.15)
17+
18+
# Set the project name
19+
set(project_name "tnco_core")
20+
project(${project_name} LANGUAGES CXX)
21+
22+
# Set the C++ standard to c++17
23+
set(CMAKE_CXX_STANDARD 17)
24+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
25+
set(CMAKE_CXX_EXTENSIONS OFF)
26+
27+
# Print build type
28+
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
29+
30+
# Add options
31+
add_compile_options(-Wall -Wpedantic -Wfatal-errors)
32+
33+
# Use FindPython or FindPython3 module
34+
find_package(Python 3.8 REQUIRED COMPONENTS Interpreter Development)
35+
36+
# Include boost library
37+
include(${CMAKE_SOURCE_DIR}/scripts/boost.cmake)
38+
39+
# Include pybind11
40+
include(${CMAKE_SOURCE_DIR}/scripts/pybind11.cmake)
41+
42+
# Include MPFR
43+
include(${CMAKE_SOURCE_DIR}/scripts/mpfr.cmake)
44+
45+
# Include TNCO headers
46+
include_directories(${CMAKE_SOURCE_DIR}/include/)
47+
48+
# Get all source files
49+
file(GLOB_RECURSE SOURCES "./include/tnco/*.cpp")
50+
51+
# Initialize PyBind11 library
52+
pybind11_add_module(${project_name} ${SOURCES})
53+
54+
# Install core
55+
install(TARGETS ${project_name} DESTINATION .)

CONTRIBUTING.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# How to Contribute
2+
3+
We would love to accept your patches and contributions to this project.
4+
5+
## Before you begin
6+
7+
### Sign our Contributor License Agreement
8+
9+
Contributions to this project must be accompanied by a
10+
[Contributor License Agreement](https://cla.developers.google.com/about) (CLA).
11+
You (or your employer) retain the copyright to your contribution; this simply
12+
gives us permission to use and redistribute your contributions as part of the
13+
project.
14+
15+
If you or your current employer have already signed the Google CLA (even if it
16+
was for a different project), you probably don't need to do it again.
17+
18+
Visit <https://cla.developers.google.com/> to see your current agreements or to
19+
sign a new one.
20+
21+
### Review our Community Guidelines
22+
23+
This project follows [Google's Open Source Community
24+
Guidelines](https://opensource.google/conduct/).
25+
26+
## Contribution process
27+
28+
### Code Reviews
29+
30+
All submissions, including submissions by project members, require review.

0 commit comments

Comments
 (0)