From ec4b87861cd0bc2fc2bcc9d5cc2650c54e55cb1e Mon Sep 17 00:00:00 2001 From: Francesco Biscani Date: Sat, 18 Jan 2025 08:36:45 +0100 Subject: [PATCH 1/5] Remove unused import. --- heyoka/expose_sgp4_propagators.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/heyoka/expose_sgp4_propagators.cpp b/heyoka/expose_sgp4_propagators.cpp index 87580cb5..f28ee0f4 100644 --- a/heyoka/expose_sgp4_propagators.cpp +++ b/heyoka/expose_sgp4_propagators.cpp @@ -291,8 +291,6 @@ void expose_sgp4_propagator_impl(py::module_ &m, const std::string &suffix) "__call__", [](prop_t &prop, std::variant, py::array_t> tm_arr, std::optional> out) -> py::array_t { - auto np = py::module_::import("numpy"); - // NOTE: here we are repeating several checks which are redundant with // checks already performed on the C++ side, with the goal of providing better // error messages. From 706eecb84080fccd663bbee72f1ed4d00d082b94 Mon Sep 17 00:00:00 2001 From: Francesco Biscani Date: Sat, 18 Jan 2025 08:39:58 +0100 Subject: [PATCH 2/5] Make the jdtype property of sgp4 propagators static. --- heyoka/expose_sgp4_propagators.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heyoka/expose_sgp4_propagators.cpp b/heyoka/expose_sgp4_propagators.cpp index f28ee0f4..12cb9f8a 100644 --- a/heyoka/expose_sgp4_propagators.cpp +++ b/heyoka/expose_sgp4_propagators.cpp @@ -204,9 +204,9 @@ void expose_sgp4_propagator_impl(py::module_ &m, const std::string &suffix) "sat_list"_a.noconvert(), "diff_order"_a.noconvert() = static_cast(0), HEYOKA_PY_CFUNC_ARGS(false), HEYOKA_PY_LLVM_STATE_ARGS, docstrings::sgp4_propagator_init(std::same_as ? "float" : "numpy.single").c_str()); - prop_cl.def_property_readonly( + prop_cl.def_property_readonly_static( "jdtype", - [](const prop_t &) -> py::object { + [](const py::object &) -> py::object { auto np = py::module_::import("numpy"); py::object dtype = np.attr("dtype"); From 497e317e6d71be0c3c44b8ba9cae634ff37b9d81 Mon Sep 17 00:00:00 2001 From: Francesco Biscani Date: Sat, 18 Jan 2025 08:53:53 +0100 Subject: [PATCH 3/5] A couple of internal doc bits. --- heyoka/expose_batch_integrators.cpp | 10 ++++++---- heyoka/taylor_expose_integrator.cpp | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/heyoka/expose_batch_integrators.cpp b/heyoka/expose_batch_integrators.cpp index 370036cc..a6a1a063 100644 --- a/heyoka/expose_batch_integrators.cpp +++ b/heyoka/expose_batch_integrators.cpp @@ -158,8 +158,9 @@ void expose_batch_integrator_impl(py::module_ &m, const std::string &suffix) // NOTE: GIL release is fine here even if the events contain // Python objects, as the event vectors are moved in - // upon construction and thus we should never end up calling - // into the interpreter. + // upon construction and thus we never end up calling + // into the interpreter. Also, due to mandatory copy elision, + // we never end up making a copy of the return value. py::gil_scoped_release release; return hey::taylor_adaptive_batch{std::move(sys), @@ -184,8 +185,9 @@ void expose_batch_integrator_impl(py::module_ &m, const std::string &suffix) // NOTE: GIL release is fine here even if the events contain // Python objects, as the event vectors are moved in - // upon construction and thus we should never end up calling - // into the interpreter. + // upon construction and thus we never end up calling + // into the interpreter. Also, due to mandatory copy elision, + // we never end up making a copy of the return value. py::gil_scoped_release release; return hey::taylor_adaptive_batch{std::move(sys), diff --git a/heyoka/taylor_expose_integrator.cpp b/heyoka/taylor_expose_integrator.cpp index 000f0c70..0808880a 100644 --- a/heyoka/taylor_expose_integrator.cpp +++ b/heyoka/taylor_expose_integrator.cpp @@ -123,7 +123,8 @@ void expose_taylor_integrator_impl(py::module &m, const std::string &suffix) // NOTE: GIL release is fine here even if the events contain // Python objects, as the event vectors are moved in // upon construction and thus we should never end up calling - // into the interpreter. + // into the interpreter. Also, due to mandatory copy elision, + // we never end up making a copy of the return value. py::gil_scoped_release release; return std::visit( From 2a8dbd6b4dca01f36c96ed6b42209e55d7f37ca2 Mon Sep 17 00:00:00 2001 From: Francesco Biscani Date: Sat, 18 Jan 2025 08:58:34 +0100 Subject: [PATCH 4/5] Revert "Make the jdtype property of sgp4 propagators static." This reverts commit 706eecb84080fccd663bbee72f1ed4d00d082b94. --- heyoka/expose_sgp4_propagators.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/heyoka/expose_sgp4_propagators.cpp b/heyoka/expose_sgp4_propagators.cpp index 12cb9f8a..f28ee0f4 100644 --- a/heyoka/expose_sgp4_propagators.cpp +++ b/heyoka/expose_sgp4_propagators.cpp @@ -204,9 +204,9 @@ void expose_sgp4_propagator_impl(py::module_ &m, const std::string &suffix) "sat_list"_a.noconvert(), "diff_order"_a.noconvert() = static_cast(0), HEYOKA_PY_CFUNC_ARGS(false), HEYOKA_PY_LLVM_STATE_ARGS, docstrings::sgp4_propagator_init(std::same_as ? "float" : "numpy.single").c_str()); - prop_cl.def_property_readonly_static( + prop_cl.def_property_readonly( "jdtype", - [](const py::object &) -> py::object { + [](const prop_t &) -> py::object { auto np = py::module_::import("numpy"); py::object dtype = np.attr("dtype"); From 7e2973e4c7260b8566b98e9ae0a78ed7b59a626c Mon Sep 17 00:00:00 2001 From: Francesco Biscani Date: Sat, 18 Jan 2025 08:59:40 +0100 Subject: [PATCH 5/5] Add explanation. --- heyoka/expose_sgp4_propagators.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/heyoka/expose_sgp4_propagators.cpp b/heyoka/expose_sgp4_propagators.cpp index f28ee0f4..c130f990 100644 --- a/heyoka/expose_sgp4_propagators.cpp +++ b/heyoka/expose_sgp4_propagators.cpp @@ -204,6 +204,9 @@ void expose_sgp4_propagator_impl(py::module_ &m, const std::string &suffix) "sat_list"_a.noconvert(), "diff_order"_a.noconvert() = static_cast(0), HEYOKA_PY_CFUNC_ARGS(false), HEYOKA_PY_LLVM_STATE_ARGS, docstrings::sgp4_propagator_init(std::same_as ? "float" : "numpy.single").c_str()); + // NOTE: this should be a static property, but at the moment doing this will mess up + // the documentation as sphinx will not pick up the docstring properly. Either we are + // doing something wrong in the docstring format or it is a genuine sphinx issue. prop_cl.def_property_readonly( "jdtype", [](const prop_t &) -> py::object {