Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions python/src/codac2_py_deprecated.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* \file
* Codac binding (core)
* ----------------------------------------------------------------------------
* \date 2026
* \author Simon Rohou
* \copyright Copyright 2026 Codac Team
* \license GNU Lesser General Public License (LGPL)
*/

#pragma once

#include <iostream>

inline void deprecated_xor()
{
std::cout
<< "Operator '^' is intentionally disabled in Codac. Use pow(x,y), sqr(x), or '**' instead."
<< std::endl;
}
27 changes: 27 additions & 0 deletions python/src/core/domains/interval/codac2_py_Interval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
#include <pybind11/operators.h>
#include <pybind11/stl.h>
#include <codac2_Interval.h>
#include <codac2_Interval_operations.h>
#include "codac2_py_Interval_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py):
#include "codac2_py_Interval_impl_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py):
#include "codac2_py_Interval_operations_impl_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py):
#include "codac2_py_matlab.h"
#include "codac2_py_deprecated.h"

using namespace std;
using namespace codac2;
Expand Down Expand Up @@ -262,6 +265,30 @@ py::class_<Interval> export_Interval(py::module& m)
INTERVAL_REF_INTERVAL_OPERATORDIVEQ_CONST_INTERVAL_REF,
"x"_a)

.def("__xor__", [](const Interval& x1, int x2) { deprecated_xor(); return codac2::pow(x1,x2); },
INTERVAL_POW_CONST_INTERVAL_REF_INT,
"n"_a)

.def("__xor__", [](const Interval& x1, double x2) { deprecated_xor(); return codac2::pow(x1,x2); },
INTERVAL_POW_CONST_INTERVAL_REF_DOUBLE,
"n"_a)

.def("__xor__", [](const Interval& x1, const Interval& x2) { deprecated_xor(); return codac2::pow(x1,x2); },
INTERVAL_POW_CONST_INTERVAL_REF_CONST_INTERVAL_REF,
"n"_a)

.def("__pow__", (Interval(*)(const Interval&,int)) &codac2::pow,
INTERVAL_POW_CONST_INTERVAL_REF_INT,
"n"_a)

.def("__pow__", (Interval(*)(const Interval&,double)) &codac2::pow,
INTERVAL_POW_CONST_INTERVAL_REF_DOUBLE,
"n"_a)

.def("__pow__", (Interval(*)(const Interval&,const Interval&)) &codac2::pow,
INTERVAL_POW_CONST_INTERVAL_REF_CONST_INTERVAL_REF,
"n"_a)

.def_static("empty", &Interval::empty,
STATIC_INTERVAL_INTERVAL_EMPTY)

Expand Down
24 changes: 8 additions & 16 deletions python/src/core/domains/interval/codac2_py_IntervalMatrixBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,56 +72,49 @@ void export_IntervalMatrixBase(py::module& m, py::class_<S>& pyclass)

.def("min_rad", [](const S& x, const std::vector<Index_type>& among_indices)
{
return x.min_rad(
among_indices.empty() ? among_indices : matlab::convert_indices(among_indices));
return x.min_rad(matlab::convert_indices(among_indices));
},
MATRIXBASE_ADDONS_INTERVALMATRIXBASE_DOUBLE_MIN_RAD_CONST_VECTOR_INDEX_REF_CONST,
"among_indices"_a=std::vector<Index_type>())

.def("max_rad", [](const S& x, const std::vector<Index_type>& among_indices)
{
return x.max_rad(
among_indices.empty() ? among_indices : matlab::convert_indices(among_indices));
return x.max_rad(matlab::convert_indices(among_indices));
},
MATRIXBASE_ADDONS_INTERVALMATRIXBASE_DOUBLE_MAX_RAD_CONST_VECTOR_INDEX_REF_CONST,
"among_indices"_a=std::vector<Index_type>())

.def("min_diam", [](const S& x, const std::vector<Index_type>& among_indices)
{
return x.min_diam(
among_indices.empty() ? among_indices : matlab::convert_indices(among_indices));
return x.min_diam(matlab::convert_indices(among_indices));
},
MATRIXBASE_ADDONS_INTERVALMATRIXBASE_DOUBLE_MIN_DIAM_CONST_VECTOR_INDEX_REF_CONST,
"among_indices"_a=std::vector<Index_type>())

.def("max_diam", [](const S& x, const std::vector<Index_type>& among_indices)
{
return x.max_diam(
among_indices.empty() ? among_indices : matlab::convert_indices(among_indices));
return x.max_diam(matlab::convert_indices(among_indices));
},
MATRIXBASE_ADDONS_INTERVALMATRIXBASE_DOUBLE_MAX_DIAM_CONST_VECTOR_INDEX_REF_CONST,
"among_indices"_a=std::vector<Index_type>())

.def("min_diam_index", [](const S& x, const std::vector<Index_type>& among_indices)
{
return matlab::output_index(x.min_diam_index(
among_indices.empty() ? among_indices : matlab::convert_indices(among_indices)));
return matlab::output_index(x.min_diam_index(matlab::convert_indices(among_indices)));
},
MATRIXBASE_ADDONS_INTERVALMATRIXBASE_INDEX_MIN_DIAM_INDEX_CONST_VECTOR_INDEX_REF_CONST,
"among_indices"_a=std::vector<Index_type>())

.def("max_diam_index", [](const S& x, const std::vector<Index_type>& among_indices)
{
return matlab::output_index(x.max_diam_index(
among_indices.empty() ? among_indices : matlab::convert_indices(among_indices)));
return matlab::output_index(x.max_diam_index(matlab::convert_indices(among_indices)));
},
MATRIXBASE_ADDONS_INTERVALMATRIXBASE_INDEX_MAX_DIAM_INDEX_CONST_VECTOR_INDEX_REF_CONST,
"among_indices"_a=std::vector<Index_type>())

.def("extr_diam_index", [](const S& x, bool min, const std::vector<Index_type>& among_indices)
{
return matlab::output_index(x.extr_diam_index(min,
among_indices.empty() ? among_indices : matlab::convert_indices(among_indices)));
return matlab::output_index(x.extr_diam_index(min,matlab::convert_indices(among_indices)));
},
MATRIXBASE_ADDONS_INTERVALMATRIXBASE_INDEX_EXTR_DIAM_INDEX_BOOL_CONST_VECTOR_INDEX_REF_CONST,
"min"_a, "among_indices"_a=std::vector<Index_type>())
Expand Down Expand Up @@ -196,8 +189,7 @@ void export_IntervalMatrixBase(py::module& m, py::class_<S>& pyclass)
.def("bisect_largest",
[](const S& x, double ratio, const std::vector<Index_type>& among_indices)
{
return x.bisect_largest(ratio,
among_indices.empty() ? among_indices : matlab::convert_indices(among_indices));
return x.bisect_largest(ratio,matlab::convert_indices(among_indices));
},
MATRIX_ADDONS_INTERVALMATRIXBASE_AUTO_BISECT_LARGEST_DOUBLE_CONST_VECTOR_INDEX_REF_CONST,
"ratio"_a = 0.49, "among_indices"_a=std::vector<Index_type>())
Expand Down
20 changes: 20 additions & 0 deletions python/src/core/domains/tube/codac2_py_SlicedTube_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <codac2_TubeBase.h>
#include "codac2_py_matlab.h"
#include "codac2_py_SlicedTube_operations_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py)
#include "codac2_py_deprecated.h"

using namespace codac2;
namespace py = pybind11;
Expand Down Expand Up @@ -401,4 +402,23 @@ void export_SlicedTube_operations(
py::is_operator());

bind_scalar_slicedtube_functions(m);

py_SlicedTube_Interval

.def("__xor__", [](const SlicedTube<Interval>& x1, int x2) { deprecated_xor(); return codac2::pow(x1,x2); },
SLICEDTUBE_INTERVAL_POW_CONST_SLICEDTUBE_INTERVAL_REF_INT,
"n"_a)

.def("__xor__", [](const SlicedTube<Interval>& x1, const Interval& x2) { deprecated_xor(); return codac2::pow(x1,x2); },
SLICEDTUBE_INTERVAL_POW_CONST_SLICEDTUBE_INTERVAL_REF_CONST_INTERVAL_REF,
"n"_a)

.def("__pow__", (SlicedTube<Interval> (*)(const SlicedTube<Interval>&,int)) &codac2::pow,
SLICEDTUBE_INTERVAL_POW_CONST_SLICEDTUBE_INTERVAL_REF_INT,
"n"_a)

.def("__pow__", (SlicedTube<Interval> (*)(const SlicedTube<Interval>&,const Interval&)) &codac2::pow,
SLICEDTUBE_INTERVAL_POW_CONST_SLICEDTUBE_INTERVAL_REF_CONST_INTERVAL_REF,
"n"_a)
;
}
18 changes: 6 additions & 12 deletions python/src/core/functions/analytic/codac2_py_AnalyticExprWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,18 @@
#include <pybind11/stl.h>
#include "codac2_AnalyticExprWrapper.h"
#include "codac2_py_matlab.h"
#include "codac2_arith_add.h"
#include "codac2_arith_sub.h"
#include "codac2_arith_mul.h"
#include "codac2_arith_div.h"
#include <codac2_arith_add.h>
#include <codac2_arith_sub.h>
#include <codac2_arith_mul.h>
#include <codac2_arith_div.h>
#include <codac2_pow.h>
#include "codac2_py_deprecated.h"
#include "codac2_py_AnalyticExprWrapper_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py)
#include "codac2_pow.h"

using namespace codac2;
namespace py = pybind11;
using namespace pybind11::literals;

inline void deprecated_xor()
{
std::cout
<< "Operator '^' is intentionally disabled in Codac. Use pow(x,y), sqr(x), or '**' instead."
<< std::endl;
}

inline void export_ScalarExpr(py::module& m)
{
py::class_<ScalarExpr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "codac2_py_analytic_variables_docs.h" // Generated file from Doxygen XML (doxygen2docstring.py):
#include "codac2_py_AnalyticExprWrapper.h"
#include "codac2_py_matlab.h"
#include "codac2_py_deprecated.h"

using namespace codac2;
namespace py = pybind11;
Expand Down