Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api/gamma #54

Open
wants to merge 86 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
082b589
Pybinding for gamma_api
Nov 27, 2022
53e621c
Add auto simplification
Nov 27, 2022
972ac19
python directory
Nov 27, 2022
855dbc0
python gamma api
Nov 27, 2022
7c2eed7
Add import_marty.py in .gitignore (generated file)
Nov 27, 2022
8c56f35
Sample notebook for gamma api
Nov 27, 2022
c49a5df
Correct tests without install
Dec 3, 2022
29abb4b
Removed direct pymartyc import
Dec 3, 2022
de7a81c
Add integration test directory
Dec 3, 2022
08858e0
First gammaAPI integration tests
Dec 3, 2022
2485dbb
Add trace() in gamma_api
Dec 4, 2022
fbee416
More gamma_api testing
Dec 4, 2022
e6f907a
Use std::exception in sgl instead of throwing enum
Dec 4, 2022
1e7334a
Correct error message
Dec 6, 2022
01d9706
Correct Chiral trace recursion identity
Dec 6, 2022
42c6ad9
Chiral trace tests pass
Dec 6, 2022
20e3472
Added permissive covariant csl::Index
Dec 11, 2022
b125853
Corrected chisholm identities
Dec 11, 2022
9952ea7
Added epsilon index ordering option
Dec 11, 2022
76b74e8
Chisholm identities tests
Dec 11, 2022
5798d1c
First Fierz identities tests
Dec 11, 2022
7f95f4b
Correct sigma commutation
Dec 11, 2022
9e388f3
Correct sigma factor in fierz basis
Dec 11, 2022
58fb46f
Add fierz identity tests
Dec 11, 2022
0077ca3
ADd Fierz basis in gamma API
Dec 11, 2022
4a8f40a
Minor changes
Dec 11, 2022
cc001fb
Add python/build in gitignore
Dec 11, 2022
383b1c9
Add order in gamma API
Dec 11, 2022
91e2a50
Correct ordering to work for any expression
Dec 11, 2022
1587487
Update gammaAPI notebook
Dec 11, 2022
858db80
Correct Double Fierz identities
Dec 24, 2022
984eb10
Add basis projection
Dec 24, 2022
36a1c21
Double fierz identity tests
Dec 24, 2022
84be142
Basis projection + tests (tests complete)
Dec 25, 2022
c000425
Rename chain -> current
Dec 25, 2022
d747a15
Update python gamma API
Dec 25, 2022
515807f
Remove print statement
Dec 25, 2022
43309e0
CSL: defaulted permissive index comparison
Dec 25, 2022
a17f870
Updated notebook for gamma API
Dec 25, 2022
e46cce1
Stub files for gamma_api
Dec 26, 2022
3f9b26c
Use copy in sglinterface functions
Dec 28, 2022
68ad36e
Update gamma_api
Dec 28, 2022
ed26080
Add _pymarty.so in .gitignore
Dec 28, 2022
0c2c534
Update gamma_api
Dec 28, 2022
a03f107
Remove object _pymarty file
Dec 28, 2022
e8ce87b
Update API
Dec 28, 2022
f4ef31f
First gamma API pythont tests
Dec 28, 2022
8dc7c6c
pytest included in cmake
Dec 28, 2022
60d9f21
Corrections
Dec 28, 2022
afff70d
Config python tests
Dec 28, 2022
7e64ee7
Patch permissive indices in sgl_to_csl
Dec 29, 2022
0b3323c
Remove pytest test report before 3.10
Dec 29, 2022
fbc90c2
Correct Gamma-API
Dec 29, 2022
34a19ff
marty-static in pybinding: avoid double defs
Dec 29, 2022
874143a
test_simple_api
Dec 29, 2022
ebfe893
Completed pymarty.gamma_api tests
Dec 29, 2022
8f58f3d
Simple fierz methods for gamma API
Dec 29, 2022
5fdc5d1
Update python config
Jan 1, 2023
2254cfb
Correct workflow file
Jan 1, 2023
dc1aaca
Update c-cpp.yml
Jan 1, 2023
0ed20d6
Correct c-cpp workflow
Jan 1, 2023
5e29b8b
Correct c-cpp workflow
Jan 1, 2023
20cccec
Test conda environment gcc12
Jan 2, 2023
db40bd7
Update c-cpp.yml
Jan 2, 2023
d2acccc
Update c-cpp.yml
Jan 2, 2023
f565904
Update c-cpp.yml
Jan 2, 2023
5898caf
Update c-cpp.yml - use setup-conda action
Jan 2, 2023
02a9ad8
Update c-cpp.yml - use setup-conda action
Jan 2, 2023
78b1fa4
Update c-cpp.yml
Jan 2, 2023
a1ef9f1
Test activate pymarty env once
Jan 2, 2023
bf42cfb
Update c-cpp.yml
Jan 2, 2023
7cf9421
Correct c-cpp.yml
Jan 2, 2023
4eec75b
correct conda env - add ipython
Jan 2, 2023
d3d3332
correct conda env
Jan 2, 2023
3a356ec
Correct conda env
Jan 2, 2023
e2aa9ab
Update c-cpp.yml
Jan 2, 2023
2d93793
Update c-cpp.yml
Jan 2, 2023
18620ad
Update c-cpp.yml
Jan 2, 2023
123c663
Update c-cpp.yml
Jan 2, 2023
707c922
Correct Looptools CMAkeLists.txt
Jan 29, 2023
48155ca
Added gammaAPI integration testsz
Jan 29, 2023
3704f25
Merge branch 'master' into api/gamma
Mar 4, 2023
96bd543
Remove conftest.py file
Mar 4, 2023
e2135d4
Delete conftest.py
docbrown1955 Mar 4, 2023
935766d
Update sample notebook
Apr 30, 2023
56c8d5a
Update notebook example
May 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 37 additions & 4 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,53 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: s-weigand/setup-conda@v1
with:
activate-conda: true
update-conda: true
- run: conda --version
- run: which python
- name: dependencies
run: sudo apt-get install coreutils build-essential gcc-12 g++-12 gfortran-12 libgsl-dev libgslcblas0 qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools dvipng lcov cmake texlive texlive-latex-extra texlive-luatex -y
run: |
sudo apt-get install coreutils build-essential gcc-12 g++-12 gfortran-12 libgsl-dev libgslcblas0 qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools dvipng lcov cmake texlive texlive-latex-extra texlive-luatex -y
conda env create -f pymarty-conda-env.yml
source ${CONDA_PREFIX}/bin/activate pymarty
- name: configure
run: |
source ${CONDA_PREFIX}/bin/activate pymarty
mkdir build
cd build
export CXX=g++-12
export CC=gcc-12
export FC=gfortran-12
cmake ..
cmake .. -DFORCE_PYMARTY_CONFIG=1
- name: make
run: |
source ${CONDA_PREFIX}/bin/activate pymarty
cd build
make
- name: install
run: |
source ${CONDA_PREFIX}/bin/activate pymarty
cd build
sudo make install
- name: test
run: |
source ${CONDA_PREFIX}/bin/activate pymarty
cd build
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
ctest --output-on-failure
build-and-test-ubuntu-gcc9:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: s-weigand/setup-conda@v1
with:
activate-conda: true
update-conda: true
- name: dependencies
run: sudo apt-get install coreutils build-essential gcc-9 g++-9 gfortran-9 libgsl-dev libgslcblas0 qt5-default dvipng lcov cmake texlive texlive-latex-extra texlive-luatex -y
run: |
sudo apt-get install coreutils build-essential gcc-9 g++-9 gfortran-9 libgsl-dev libgslcblas0 qt5-default dvipng lcov cmake texlive texlive-latex-extra texlive-luatex -y
- name: configure
run: |
mkdir build
Expand All @@ -70,10 +88,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: s-weigand/setup-conda@v1
with:
activate-conda: true
update-conda: true
- name: dependencies
run: sudo apt-get install coreutils build-essential clang gfortran libgsl-dev libgslcblas0 qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools dvipng cmake lcov texlive texlive-latex-extra texlive-luatex -y
run: |
sudo apt-get install coreutils build-essential clang gfortran libgsl-dev libgslcblas0 qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools dvipng cmake lcov texlive texlive-latex-extra texlive-luatex -y
conda env create -f pymarty-conda-env.yml
source ${CONDA_PREFIX}/bin/activate pymarty
- name: configure
run: |
source ${CONDA_PREFIX}/bin/activate pymarty
mkdir build
cd build
export CXX=clang++
Expand All @@ -82,21 +108,28 @@ jobs:
cmake ..
- name: make
run: |
source ${CONDA_PREFIX}/bin/activate pymarty
cd build
make
- name: install
run: |
source ${CONDA_PREFIX}/bin/activate pymarty
cd build
sudo make install
- name: test
run: |
source ${CONDA_PREFIX}/bin/activate pymarty
cd build
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
ctest --output-on-failure
build-and-test-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: s-weigand/setup-conda@v1
with:
activate-conda: true
update-conda: true
- name: dependencies
run: |
brew install coreutils gcc@12 gsl qt5 cmake lcov imagemagick texlive octave pkg-config
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ marty_env.sh
build/*
.vscode
*.sw[p-z]
*.so
27 changes: 27 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,25 @@ set(LLVM_COMPILERS 0)
set(REQUIRED_COMPILER_VERSION 0)
set(IDENTICAL_COMPILER_VERSION 0)

# Config for Pymarty
if (NOT PYMARTY_PYTHON_VERSION)
find_package(Python COMPONENTS Interpreter Development)
else()
find_package(Python EXACT ${PYMARTY_PYTHON_VERSION} COMPONENTS Interpreter Development)
set(PYBIND11_PYTHON_VERSION ${PYMARTY_PYTHON_VERSION} CACHE STRING "")
endif()
find_package(pybind11 CONFIG)

if (Python_FOUND AND pybind11_FOUND)
set(CONFIGURE_PYMARTY ON)
else()
message(WARNING "Cannot configure pybindings for MARTY. Python or pybind11 are missing.")
set(CONFIGURE_PYMARTY OFF)
endif()
if (FORCE_PYMARTY_CONFIG AND (NOT CONFIGURE_PYMARTY))
message(FATAL_ERROR "The variable FORCE_PYMARTY_CONFIG was set to 1 but pymarty cannot be configured, aborting configuration.")
endif()

find_package(GSL REQUIRED)

# Dependencies for GRAFED
Expand Down Expand Up @@ -94,10 +113,18 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
add_subdirectory(dep)
add_subdirectory(src)
add_subdirectory(examples)
if (CONFIGURE_PYMARTY)
add_subdirectory(python)
endif()

add_subdirectory(tests)

install(TARGETS marty marty-static csl csl-static marty-lha marty-lha-static marty-gamma-api
DESTINATION lib)
if (CONFIGURE_PYMARTY)
install(PROGRAMS "$<TARGET_FILE:_pymarty>"
DESTINATION lib)
endif()
install(DIRECTORY src/
DESTINATION include
FILES_MATCHING PATTERN *.h)
Expand Down
11 changes: 11 additions & 0 deletions pymarty-conda-env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: pymarty
channels:
- defaults
dependencies:
- ipython
- matplotlib
- numpy
- pybind11
- pytest
- python
- scipy
5 changes: 5 additions & 0 deletions python/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
__pycache__
*checkpoint.ipynb
*.egg-info
build
tests/conftest.py
13 changes: 13 additions & 0 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
enable_testing()

include(Pytest.cmake)

pytest_discover_tests(
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
TEST_PREFIX "PYUNITTEST_"
TEST_SUFFIX ""
# XML_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/report
)

set(PYMARTY_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src)
configure_file(tests/conftest.py.in ${CMAKE_CURRENT_SOURCE_DIR}/tests/conftest.py @ONLY)
139 changes: 139 additions & 0 deletions python/Pytest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Distributed under the OSI-approved BSD 3-Clause License.

#[=======================================================================[.rst:
Pytest
----------

This module defines functions to help integrate Pytest scripts into CMake.

.. command:: pytest_discover_tests

Automatically add tests with CTest by querying the compiled test executable
for available tests::

pytest_discover_tests([EXTRA_ARGS arg1...]
[WORKING_DIRECTORY dir]
[TEST_PREFIX prefix]
[TEST_SUFFIX suffix]
[XML_OUTPUT_DIR dir]
)

``pytest_discover_tests()`` will collect all pytest test cases and register
commands that execute them through CTest.

The main advantage of using this instead of just calling pytest directly is
that you can synchronize filtering and other configuration within CMake. The
only disadvantage of using this however is that pytest does test collection
whether or not test filtering is used, so this can add significant overhead.

The options are:

``EXTRA_ARGS arg1...``
Any extra arguments to pass on the command line to pytest

``COLLECTION_ARGS arg1...``
Extra arguments to pass to pytest during test case collection

``EXECUTION_ARGS arg1...``
Extra arguments to pass to pytest during test case execution

``WORKING_DIRECTORY dir``
Specifies the directory in which to run test case collection and test case
execution. If this
option is not provided, the current source directory is used.

``TEST_PREFIX prefix``
Specifies a ``prefix`` to be prepended to the name of each discovered test
case. This can be useful when using multiple test folders and there are
potentially clashing test names, it can also make test filtering in presets
easier. If this option is not provided then the prefix is empty.

``TEST_SUFFIX suffix``
Similar to ``TEST_PREFIX`` except the ``suffix`` is appended to the name of
every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may
be specified.

``XML_OUTPUT_DIR dir``

If specified, the parameter is passed along with ``--junitxml=<test name>``
to test executable. The actual file name is the same as the test target,
including prefix and suffix.

#]=======================================================================]

cmake_policy(PUSH)

#------------------------------------------------------------------------------
function(pytest_discover_tests)

cmake_parse_arguments(
""
""
"TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;XML_OUTPUT_DIR"
"EXTRA_ARGS;COLLECTION_ARGS;EXECUTION_ARGS"
${ARGN}
)

# Default settings
if(NOT _WORKING_DIRECTORY)
set(_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
endif()

# https://docs.pytest.org/en/6.2.x/example/pythoncollection.html#finding-out-what-is-collected
set(pytest_collection_args --collect-only -q ${_EXTRA_ARGS} ${_COLLECTION_ARGS})
set(pytest_execution_args ${_EXTRA_ARGS} ${_EXECUTION_ARGS})
set(pytest_base_command pytest)

execute_process(
COMMAND ${pytest_base_command} ${pytest_collection_args}
WORKING_DIRECTORY ${_WORKING_DIRECTORY}
OUTPUT_VARIABLE pytest_collect_output
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE pytest_collect_result
)
if(NOT ${pytest_collect_result} EQUAL 0)
message(WARNING "Error running Pytest discovery, tests for the python API will not be ran...")
return()
endif()

# Splits lines into a list variable
string(REPLACE [[;]] [[\;]] pytest_collect_output "${pytest_collect_output}")
string(REPLACE "\n" ";" pytest_collect_output "${pytest_collect_output}")

set(pytest_testcase_regex "([^:]+)(::([^:]+))?::([^:]+)")

foreach(test_case ${pytest_collect_output})
string(REGEX MATCHALL ${pytest_testcase_regex} test_case_match "${test_case}")

if(test_case_match)
set(test_case_file ${CMAKE_MATCH_1})
set(test_case_class ${CMAKE_MATCH_3})
set(test_case_func ${CMAKE_MATCH_4})

if(test_case_class)
set(test_case_name "${_TEST_PREFIX}${test_case_class}.${test_case_func}${_TEST_SUFFIX}")
else()
set(test_case_name "${_TEST_PREFIX}${test_case_func}${_TEST_SUFFIX}")
endif()

if(_XML_OUTPUT_DIR)
set(pytest_local_args --junitxml=${_XML_OUTPUT_DIR}/${test_case_name}.xml)
endif()

add_test(
NAME "${test_case_name}"
COMMAND ${pytest_base_command}
${test_case} ${pytest_execution_args} ${pytest_local_args}
WORKING_DIRECTORY ${_WORKING_DIRECTORY}
)
# Pytest Exit code 5 means all tests were deselected
set_tests_properties("${test_case_name}" PROPERTIES SKIP_RETURN_CODE 5)
endif()

endforeach()

endfunction()

#------------------------------------------------------------------------------

cmake_policy(POP)
1 change: 1 addition & 0 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# PyMarty
Loading