Skip to content

Commit

Permalink
Merge branch 'codac2' into codac2_ellipsoids
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonRohou committed Oct 19, 2024
2 parents ad4e475 + 8ec43c7 commit f5b8823
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dockercentos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
branches:
- codac2
- codac4matlab
- codac2_codac4matlab
tags: '' # Restrict to blank tags
pull_request:

Expand Down Expand Up @@ -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'))
1 change: 1 addition & 0 deletions .github/workflows/dockermatrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches: 'codac2'
tags: '' # Restrict to blank tags
pull_request:
branches: 'codac2'

jobs:
dockermatrix:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/macosmatrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
branches:
- codac2
- codac4matlab
- codac2_codac4matlab
tags: '' # Restrict to blank tags
pull_request:

Expand Down Expand Up @@ -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
Expand All @@ -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!='codac2_codac4matlab') && (github.event_name!='pull_request')
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Unit tests
on:
push:
branches: '**'
branches-ignore:
- codac2_codac4matlab
tags: '' # Restrict to blank tags
pull_request:

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unixmatrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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!='codac2_codac4matlab') && (github.event_name!='pull_request')
- run: |
source ~/refreshenv.bashrc ; refreshenv ; export PATH=$BASHMINGWPATH:$PATH
cd packages/choco
Expand Down Expand Up @@ -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!='codac2_codac4matlab') && (github.event_name!='pull_request')
6 changes: 3 additions & 3 deletions .github/workflows/vcmatrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
branches:
- codac2
- codac4matlab
- codac2_codac4matlab
tags: '' # Restrict to blank tags
pull_request:

Expand Down Expand Up @@ -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
Expand All @@ -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!='codac2_codac4matlab') && (github.event_name!='pull_request')
41 changes: 23 additions & 18 deletions python/src/core/separators/codac2_py_SepProj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,42 @@ using namespace codac2;
namespace py = pybind11;
using namespace pybind11::literals;

vector<size_t> test_and_convert(const vector<size_t_type>& indices)
{
#if FOR_MATLAB

vector<size_t> 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;

#endif
}

void export_SepProj(py::module& m, py::class_<SepBase,pySep>& pysep)
{
py::class_<SepProj> exported(m, "SepProj", pysep, SEPPROJ_MAIN);
exported

.def(py::init(
[](const SepBase& s, std::vector<size_t_type> proj_indices, double default_eps)
[](const SepBase& s, vector<size_t_type> 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<SepProj>(s.copy(), proj_indices, default_eps);
return make_unique<SepProj>(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<size_t_type> proj_indices, const IntervalVector& y, double default_eps)
[](const SepBase& s, vector<size_t_type> 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<SepProj>(s.copy(), proj_indices, y, default_eps);
return make_unique<SepProj>(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)
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
# Generating file for #include <codac>
# ====================================

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})
Expand Down
6 changes: 3 additions & 3 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,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)


################################################################################
Expand All @@ -193,8 +193,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})
Expand Down
6 changes: 3 additions & 3 deletions src/graphics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)


################################################################################
Expand All @@ -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})
Expand Down
4 changes: 2 additions & 2 deletions src/sympy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
6 changes: 3 additions & 3 deletions src/unsupported/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)


################################################################################
Expand All @@ -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})
Expand Down

0 comments on commit f5b8823

Please sign in to comment.