Skip to content

Commit

Permalink
add python complex interface
Browse files Browse the repository at this point in the history
  • Loading branch information
j8xixo12 committed Jan 2, 2025
1 parent 8e0586c commit c2525fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 0 additions & 1 deletion cpp/modmesh/mathtype/pymod/mathtype_pymod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*/

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

#include <modmesh/python/common.hpp>

Expand Down
5 changes: 4 additions & 1 deletion cpp/modmesh/mathtype/pymod/wrap_Complex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ class MODMESH_PYTHON_WRAPPER_VISIBILITY WrapComplex
.def(py::self -= py::self) // NOLINT(misc-redundant-expression)
.def_property_readonly("real", &wrapped_type::real)
.def_property_readonly("imag", &wrapped_type::imag)
.def("norm", &wrapped_type::norm);
.def("norm", &wrapped_type::norm)
.def("__complex__",
[](wrapped_type const & self)
{ return std::complex<T>(self.real(), self.imag()); });
}

}; /* end class WrapComplex */
Expand Down

0 comments on commit c2525fe

Please sign in to comment.