From aa7b8b1499a41aef8e3096769af977ca805336f9 Mon Sep 17 00:00:00 2001 From: Simon Rohou Date: Sat, 19 Oct 2024 11:58:00 +0200 Subject: [PATCH 1/7] [github] updated github actions files (restoring config from old codac4matlab branch --- .github/workflows/dockermatrix.yml | 1 + .github/workflows/macosmatrix.yml | 2 +- .github/workflows/unixmatrix.yml | 4 ++-- .github/workflows/vcmatrix.yml | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dockermatrix.yml b/.github/workflows/dockermatrix.yml index f25f93e5..fcb20b5d 100644 --- a/.github/workflows/dockermatrix.yml +++ b/.github/workflows/dockermatrix.yml @@ -4,6 +4,7 @@ on: branches: 'codac2' tags: '' # Restrict to blank tags pull_request: + branches: 'codac2' jobs: dockermatrix: diff --git a/.github/workflows/macosmatrix.yml b/.github/workflows/macosmatrix.yml index f48ae39d..ed1b80d8 100644 --- a/.github/workflows/macosmatrix.yml +++ b/.github/workflows/macosmatrix.yml @@ -85,4 +85,4 @@ jobs: cd build && ctest -C Release -V --output-on-failure cd .. shell: bash - if: (matrix.cfg.cross!=true)&&(github.ref_name!='codac4matlab') + if: (matrix.cfg.cross!=true) && (github.ref_name!='codac4matlab') && (github.event_name!='pull_request') \ No newline at end of file diff --git a/.github/workflows/unixmatrix.yml b/.github/workflows/unixmatrix.yml index b6638651..52e7ff6d 100644 --- a/.github/workflows/unixmatrix.yml +++ b/.github/workflows/unixmatrix.yml @@ -179,7 +179,7 @@ jobs: ./${{ matrix.cfg.test_config }}my_project cd ../.. shell: bash - if: (matrix.cfg.cross!=true)&&(github.ref_name!='codac4matlab') + if: (matrix.cfg.cross!=true) && (github.ref_name!='codac4matlab') && (github.event_name!='pull_request') - run: | source ~/refreshenv.bashrc ; refreshenv ; export PATH=$BASHMINGWPATH:$PATH cd packages/choco @@ -231,4 +231,4 @@ jobs: ./${{ matrix.cfg.test_config }}my_project cd ../.. shell: bash - if: (matrix.cfg.cross!=true)&&(github.ref_name!='codac4matlab') + if: (matrix.cfg.cross!=true) && (github.ref_name!='codac4matlab') && (github.event_name!='pull_request') diff --git a/.github/workflows/vcmatrix.yml b/.github/workflows/vcmatrix.yml index f9f3ba78..b06e0d5b 100644 --- a/.github/workflows/vcmatrix.yml +++ b/.github/workflows/vcmatrix.yml @@ -86,4 +86,4 @@ jobs: cd build && ctest -C Release -V --output-on-failure cd .. shell: bash - if: (github.ref_name!='codac4matlab') + if: (github.ref_name!='codac4matlab') && (github.event_name!='pull_request') From a8b7cc33db350675013f14d0d0d4138c703f6b2b Mon Sep 17 00:00:00 2001 From: Simon Rohou Date: Sat, 19 Oct 2024 12:04:17 +0200 Subject: [PATCH 2/7] [github] actions: codac4matlab -> codac2_codac4matlab --- .github/workflows/dockercentos.yml | 4 ++-- .github/workflows/macosmatrix.yml | 6 +++--- .github/workflows/unixmatrix.yml | 4 ++-- .github/workflows/vcmatrix.yml | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/dockercentos.yml b/.github/workflows/dockercentos.yml index fc86d680..e1f1a799 100644 --- a/.github/workflows/dockercentos.yml +++ b/.github/workflows/dockercentos.yml @@ -3,7 +3,7 @@ on: push: branches: - codac2 - - codac4matlab + - codac2_codac4matlab tags: '' # Restrict to blank tags pull_request: @@ -42,4 +42,4 @@ jobs: file: "wheelhouse/*.whl" overwrite: true tag_name: autotagname-${{ github.sha }} - if: (github.event_name!='pull_request')&&((github.ref_name=='codac2')||(github.ref_name=='codac4matlab')) + if: (github.event_name!='pull_request')&&((github.ref_name=='codac2')||(github.ref_name=='codac2_codac4matlab')) diff --git a/.github/workflows/macosmatrix.yml b/.github/workflows/macosmatrix.yml index ed1b80d8..edc85f60 100644 --- a/.github/workflows/macosmatrix.yml +++ b/.github/workflows/macosmatrix.yml @@ -3,7 +3,7 @@ on: push: branches: - codac2 - - codac4matlab + - codac2_codac4matlab tags: '' # Restrict to blank tags pull_request: @@ -76,7 +76,7 @@ jobs: file: "*.whl" overwrite: true tag_name: autotagname-${{ github.sha }} - if: (github.event_name!='pull_request')&&((github.ref_name=='codac2')||(github.ref_name=='codac4matlab')) + if: (github.event_name!='pull_request')&&((github.ref_name=='codac2')||(github.ref_name=='codac2_codac4matlab')) - run: | pip install --no-deps --no-index *.whl python -c "import sys; print(sys.version)" ; python examples/02_centered_form/main.py @@ -85,4 +85,4 @@ jobs: cd build && ctest -C Release -V --output-on-failure cd .. shell: bash - if: (matrix.cfg.cross!=true) && (github.ref_name!='codac4matlab') && (github.event_name!='pull_request') \ No newline at end of file + if: (matrix.cfg.cross!=true) && (github.ref_name!='codac2_codac4matlab') && (github.event_name!='pull_request') \ No newline at end of file diff --git a/.github/workflows/unixmatrix.yml b/.github/workflows/unixmatrix.yml index 52e7ff6d..2319e099 100644 --- a/.github/workflows/unixmatrix.yml +++ b/.github/workflows/unixmatrix.yml @@ -179,7 +179,7 @@ jobs: ./${{ matrix.cfg.test_config }}my_project cd ../.. shell: bash - if: (matrix.cfg.cross!=true) && (github.ref_name!='codac4matlab') && (github.event_name!='pull_request') + if: (matrix.cfg.cross!=true) && (github.ref_name!='codac2_codac4matlab') && (github.event_name!='pull_request') - run: | source ~/refreshenv.bashrc ; refreshenv ; export PATH=$BASHMINGWPATH:$PATH cd packages/choco @@ -231,4 +231,4 @@ jobs: ./${{ matrix.cfg.test_config }}my_project cd ../.. shell: bash - if: (matrix.cfg.cross!=true) && (github.ref_name!='codac4matlab') && (github.event_name!='pull_request') + if: (matrix.cfg.cross!=true) && (github.ref_name!='codac2_codac4matlab') && (github.event_name!='pull_request') diff --git a/.github/workflows/vcmatrix.yml b/.github/workflows/vcmatrix.yml index b06e0d5b..34b163a4 100644 --- a/.github/workflows/vcmatrix.yml +++ b/.github/workflows/vcmatrix.yml @@ -3,7 +3,7 @@ on: push: branches: - codac2 - - codac4matlab + - codac2_codac4matlab tags: '' # Restrict to blank tags pull_request: @@ -77,7 +77,7 @@ jobs: file: "*.whl" overwrite: true tag_name: autotagname-${{ github.sha }} - if: (github.event_name!='pull_request')&&((github.ref_name=='codac2')||(github.ref_name=='codac4matlab')) + if: (github.event_name!='pull_request')&&((github.ref_name=='codac2')||(github.ref_name=='codac2_codac4matlab')) - run: | pip install --no-deps --no-index *.whl python -c "import sys; print(sys.version)" ; python examples/02_centered_form/main.py @@ -86,4 +86,4 @@ jobs: cd build && ctest -C Release -V --output-on-failure cd .. shell: bash - if: (github.ref_name!='codac4matlab') && (github.event_name!='pull_request') + if: (github.ref_name!='codac2_codac4matlab') && (github.event_name!='pull_request') From 9b9dd3a465e8b75b27e0dd128bc57ebd4ad7046d Mon Sep 17 00:00:00 2001 From: Simon Rohou Date: Sat, 19 Oct 2024 14:32:29 +0200 Subject: [PATCH 3/7] [cmake] using PROJECT_NAME instead of 'codac' (codac4matlab) --- src/CMakeLists.txt | 2 +- src/core/CMakeLists.txt | 6 +++--- src/graphics/CMakeLists.txt | 6 +++--- src/sympy/CMakeLists.txt | 4 ++-- src/unsupported/CMakeLists.txt | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d496638c..f146faa7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -115,7 +115,7 @@ # Generating file for #include # ==================================== - set(CODAC_MAIN_HEADER ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}) + set(CODAC_MAIN_HEADER ${CMAKE_CURRENT_BINARY_DIR}/codac) file(WRITE ${CODAC_MAIN_HEADER} "/* This file is generated by CMake */\n\n") file(APPEND ${CODAC_MAIN_HEADER} "#pragma once\n\n") foreach(header_path ${CODAC_MAIN_SUBHEADERS}) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 216cd50a..131410ed 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -162,7 +162,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/separators ${CMAKE_CURRENT_SOURCE_DIR}/tools ) - target_link_libraries(${PROJECT_NAME}-core PUBLIC codac-graphics Ibex::ibex Eigen3::Eigen) + target_link_libraries(${PROJECT_NAME}-core PUBLIC ${PROJECT_NAME}-graphics Ibex::ibex Eigen3::Eigen) ################################################################################ @@ -188,8 +188,8 @@ # Generating the file codac-core.h - set(CODAC_CORE_MAIN_HEADER ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-core.h) - set(CODAC_MAIN_SUBHEADERS ${CODAC_MAIN_SUBHEADERS} "${PROJECT_NAME}-core.h" PARENT_SCOPE) + set(CODAC_CORE_MAIN_HEADER ${CMAKE_CURRENT_BINARY_DIR}/codac-core.h) + set(CODAC_MAIN_SUBHEADERS ${CODAC_MAIN_SUBHEADERS} "codac-core.h" PARENT_SCOPE) file(WRITE ${CODAC_CORE_MAIN_HEADER} "/* This file is generated by CMake */\n\n") file(APPEND ${CODAC_CORE_MAIN_HEADER} "#pragma once\n\n") foreach(header_path ${CODAC_CORE_HDR}) diff --git a/src/graphics/CMakeLists.txt b/src/graphics/CMakeLists.txt index 65cfb8f6..7b38751b 100644 --- a/src/graphics/CMakeLists.txt +++ b/src/graphics/CMakeLists.txt @@ -43,7 +43,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/paver ${CMAKE_CURRENT_SOURCE_DIR}/styles ) - target_link_libraries(${PROJECT_NAME}-graphics PUBLIC codac-core Ibex::ibex Eigen3::Eigen) + target_link_libraries(${PROJECT_NAME}-graphics PUBLIC ${PROJECT_NAME}-core Ibex::ibex Eigen3::Eigen) ################################################################################ @@ -69,8 +69,8 @@ # Generating the file codac-graphics.h - set(CODAC_GRAPHICS_MAIN_HEADER ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-graphics.h) - set(CODAC_MAIN_SUBHEADERS ${CODAC_MAIN_SUBHEADERS} "${PROJECT_NAME}-graphics.h" PARENT_SCOPE) + set(CODAC_GRAPHICS_MAIN_HEADER ${CMAKE_CURRENT_BINARY_DIR}/codac-graphics.h) + set(CODAC_MAIN_SUBHEADERS ${CODAC_MAIN_SUBHEADERS} "codac-graphics.h" PARENT_SCOPE) file(WRITE ${CODAC_GRAPHICS_MAIN_HEADER} "/* This file is generated by CMake */\n\n") file(APPEND ${CODAC_GRAPHICS_MAIN_HEADER} "#pragma once\n\n") foreach(header_path ${CODAC_GRAPHICS_HDR}) diff --git a/src/sympy/CMakeLists.txt b/src/sympy/CMakeLists.txt index 0c07e33c..0c1bfaf2 100644 --- a/src/sympy/CMakeLists.txt +++ b/src/sympy/CMakeLists.txt @@ -58,8 +58,8 @@ # Generating the file codac-sympy.h - set(CODAC_SYMPY_MAIN_HEADER ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-sympy.h) - set(CODAC_MAIN_SUBHEADERS ${CODAC_MAIN_SUBHEADERS} "${PROJECT_NAME}-sympy.h" PARENT_SCOPE) + set(CODAC_SYMPY_MAIN_HEADER ${CMAKE_CURRENT_BINARY_DIR}/codac-sympy.h) + set(CODAC_MAIN_SUBHEADERS ${CODAC_MAIN_SUBHEADERS} "codac-sympy.h" PARENT_SCOPE) file(WRITE ${CODAC_SYMPY_MAIN_HEADER} "/* This file is generated by CMake */\n\n") file(APPEND ${CODAC_SYMPY_MAIN_HEADER} "#pragma once\n\n") foreach(header_path ${CODAC_SYMPY_HDR}) diff --git a/src/unsupported/CMakeLists.txt b/src/unsupported/CMakeLists.txt index 88998efb..efe34195 100644 --- a/src/unsupported/CMakeLists.txt +++ b/src/unsupported/CMakeLists.txt @@ -25,7 +25,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/paver ${CMAKE_CURRENT_SOURCE_DIR}/styles ) - target_link_libraries(${PROJECT_NAME}-unsupported PUBLIC codac-core Ibex::ibex Eigen3::Eigen) + target_link_libraries(${PROJECT_NAME}-unsupported PUBLIC ${PROJECT_NAME}-core Ibex::ibex Eigen3::Eigen) ################################################################################ @@ -51,8 +51,8 @@ # Generating the file codac-unsupported.h - set(CODAC_UNSUPPORTED_MAIN_HEADER ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-unsupported.h) - set(CODAC_MAIN_SUBHEADERS ${CODAC_MAIN_SUBHEADERS} "${PROJECT_NAME}-unsupported.h" PARENT_SCOPE) + set(CODAC_UNSUPPORTED_MAIN_HEADER ${CMAKE_CURRENT_BINARY_DIR}/codac-unsupported.h) + set(CODAC_MAIN_SUBHEADERS ${CODAC_MAIN_SUBHEADERS} "codac-unsupported.h" PARENT_SCOPE) file(WRITE ${CODAC_UNSUPPORTED_MAIN_HEADER} "/* This file is generated by CMake */\n\n") file(APPEND ${CODAC_UNSUPPORTED_MAIN_HEADER} "#pragma once\n\n") foreach(header_path ${CODAC_UNSUPPORTED_HDR}) From 01fc105f1676716373764fcf250541546f789b6f Mon Sep 17 00:00:00 2001 From: Simon Rohou Date: Sat, 19 Oct 2024 17:24:38 +0200 Subject: [PATCH 4/7] [matlab] corrected SepProj for Matlab binding --- .../src/core/separators/codac2_py_SepProj.cpp | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/python/src/core/separators/codac2_py_SepProj.cpp b/python/src/core/separators/codac2_py_SepProj.cpp index 9ba8f6c3..9fe8b938 100644 --- a/python/src/core/separators/codac2_py_SepProj.cpp +++ b/python/src/core/separators/codac2_py_SepProj.cpp @@ -27,14 +27,13 @@ void export_SepProj(py::module& m, py::class_& pysep) .def(py::init( [](const SepBase& s, std::vector proj_indices, double default_eps) { - std::transform(std::begin(proj_indices),std::end(proj_indices),std::begin(proj_indices), - [](size_t_type x) - { - matlab::test_integer(x); - return matlab::input_index(x); - }); - - return std::make_unique(s.copy(), proj_indices, default_eps); + std::vector proj_indices_size_t(proj_indices.size()); + for(size_t i = 0 ; i < proj_indices.size() ; i++) + { + matlab::test_integer(proj_indices[i]); + proj_indices_size_t[i] = matlab::input_index(proj_indices[i]); + } + return std::make_unique(s.copy(), proj_indices_size_t, default_eps); }), SEPPROJ_SEPPROJ_CONST_S_REF_CONST_VECTOR_SIZET_REF_DOUBLE, "s"_a, "proj_indices"_a, "default_eps"_a=0.01) @@ -42,14 +41,13 @@ void export_SepProj(py::module& m, py::class_& pysep) .def(py::init( [](const SepBase& s, std::vector proj_indices, const IntervalVector& y, double default_eps) { - std::transform(std::begin(proj_indices),std::end(proj_indices),std::begin(proj_indices), - [](size_t_type x) - { - matlab::test_integer(x); - return matlab::input_index(x); - }); - - return std::make_unique(s.copy(), proj_indices, y, default_eps); + std::vector proj_indices_size_t(proj_indices.size()); + for(size_t i = 0 ; i < proj_indices.size() ; i++) + { + matlab::test_integer(proj_indices[i]); + proj_indices_size_t[i] = matlab::input_index(proj_indices[i]); + } + return std::make_unique(s.copy(), proj_indices_size_t, y, default_eps); }), SEPPROJ_SEPPROJ_CONST_S_REF_CONST_VECTOR_SIZET_REF_CONST_INTERVALVECTOR_REF_DOUBLE, "s"_a, "proj_indices"_a, "y"_a, "default_eps"_a=0.01) From 62faad7b424d5e1c076ef11498c27f4cf363135c Mon Sep 17 00:00:00 2001 From: Simon Rohou Date: Sat, 19 Oct 2024 17:32:14 +0200 Subject: [PATCH 5/7] [matlab] corrected SepProj for Matlab binding (factorization) --- .../src/core/separators/codac2_py_SepProj.cpp | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/python/src/core/separators/codac2_py_SepProj.cpp b/python/src/core/separators/codac2_py_SepProj.cpp index 9fe8b938..104cc171 100644 --- a/python/src/core/separators/codac2_py_SepProj.cpp +++ b/python/src/core/separators/codac2_py_SepProj.cpp @@ -19,35 +19,40 @@ using namespace codac2; namespace py = pybind11; using namespace pybind11::literals; +vector test_and_convert(const vector& indices) +{ + if constexpr(FOR_MATLAB) + { + vector indices_size_t(indices.size()); + + for(size_t i = 0 ; i < indices.size() ; i++) + { + matlab::test_integer(indices[i]); + indices_size_t[i] = matlab::input_index(indices[i]); + } + } + + else // same types: size_t_type == size_t + return indices; +} + void export_SepProj(py::module& m, py::class_& pysep) { py::class_ exported(m, "SepProj", pysep, SEPPROJ_MAIN); exported .def(py::init( - [](const SepBase& s, std::vector proj_indices, double default_eps) + [](const SepBase& s, vector proj_indices, double default_eps) { - std::vector proj_indices_size_t(proj_indices.size()); - for(size_t i = 0 ; i < proj_indices.size() ; i++) - { - matlab::test_integer(proj_indices[i]); - proj_indices_size_t[i] = matlab::input_index(proj_indices[i]); - } - return std::make_unique(s.copy(), proj_indices_size_t, default_eps); + return make_unique(s.copy(), test_and_convert(proj_indices), default_eps); }), SEPPROJ_SEPPROJ_CONST_S_REF_CONST_VECTOR_SIZET_REF_DOUBLE, "s"_a, "proj_indices"_a, "default_eps"_a=0.01) .def(py::init( - [](const SepBase& s, std::vector proj_indices, const IntervalVector& y, double default_eps) + [](const SepBase& s, vector proj_indices, const IntervalVector& y, double default_eps) { - std::vector proj_indices_size_t(proj_indices.size()); - for(size_t i = 0 ; i < proj_indices.size() ; i++) - { - matlab::test_integer(proj_indices[i]); - proj_indices_size_t[i] = matlab::input_index(proj_indices[i]); - } - return std::make_unique(s.copy(), proj_indices_size_t, y, default_eps); + return make_unique(s.copy(), test_and_convert(proj_indices), y, default_eps); }), SEPPROJ_SEPPROJ_CONST_S_REF_CONST_VECTOR_SIZET_REF_CONST_INTERVALVECTOR_REF_DOUBLE, "s"_a, "proj_indices"_a, "y"_a, "default_eps"_a=0.01) From f407ee7fe0f189c97522cc637846019c53a1099f Mon Sep 17 00:00:00 2001 From: Simon Rohou Date: Sat, 19 Oct 2024 17:46:12 +0200 Subject: [PATCH 6/7] [matlab] adaptations for Matlab binding --- .github/workflows/tests.yml | 2 ++ python/src/core/separators/codac2_py_SepProj.cpp | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d88b5a62..0541adfd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,6 +2,8 @@ on: push: branches: '**' + branches-ignore: + - codac2_codac4matlab tags: '' # Restrict to blank tags pull_request: diff --git a/python/src/core/separators/codac2_py_SepProj.cpp b/python/src/core/separators/codac2_py_SepProj.cpp index 104cc171..0ec43047 100644 --- a/python/src/core/separators/codac2_py_SepProj.cpp +++ b/python/src/core/separators/codac2_py_SepProj.cpp @@ -21,8 +21,8 @@ using namespace pybind11::literals; vector test_and_convert(const vector& indices) { - if constexpr(FOR_MATLAB) - { + #if FOR_MATLAB + vector indices_size_t(indices.size()); for(size_t i = 0 ; i < indices.size() ; i++) @@ -30,10 +30,12 @@ vector test_and_convert(const vector& indices) matlab::test_integer(indices[i]); indices_size_t[i] = matlab::input_index(indices[i]); } - } - else // same types: size_t_type == size_t + #else // same types: size_t_type == size_t + return indices; + + #endif } void export_SepProj(py::module& m, py::class_& pysep) From 8ec43c72b0184a1d3cd0435d86b560d5abe8cbfc Mon Sep 17 00:00:00 2001 From: Simon Rohou Date: Sat, 19 Oct 2024 17:53:18 +0200 Subject: [PATCH 7/7] [actions] corrected tests.yml (ignoring Matlab branch) --- .github/workflows/tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0541adfd..f9b03791 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,7 +1,6 @@ # Unit tests on: push: - branches: '**' branches-ignore: - codac2_codac4matlab tags: '' # Restrict to blank tags