Skip to content

Commit

Permalink
planet getters exposed as attributes too
Browse files Browse the repository at this point in the history
  • Loading branch information
darioizzo committed Jan 7, 2025
1 parent 2d15af6 commit b952ff9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions pykep/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,22 @@ PYBIND11_MODULE(core, m) // NOLINT
PYKEP3_EXPOSE_PLANET_GETTER(radius);
PYKEP3_EXPOSE_PLANET_GETTER(safe_radius);

#undef PYKEP3_EXPOSE_PLANET_GETTER

// We also support the various quantities as attributes for compatibility with pykep 2
// and because its nicer syntax to have them as attributes.
#define PYKEP3_EXPOSE_PLANET_ATTRIBUTE(name) \
planet_class.def_property_readonly( \
#name, [](const kep3::planet &pl) { return pl.get_##name(); }, \
pykep::planet_get_##name##_docstring().c_str());

PYKEP3_EXPOSE_PLANET_ATTRIBUTE(name);
PYKEP3_EXPOSE_PLANET_ATTRIBUTE(extra_info);
PYKEP3_EXPOSE_PLANET_ATTRIBUTE(mu_central_body);
PYKEP3_EXPOSE_PLANET_ATTRIBUTE(mu_self);
PYKEP3_EXPOSE_PLANET_ATTRIBUTE(radius);
PYKEP3_EXPOSE_PLANET_ATTRIBUTE(safe_radius);

#undef PYKEP3_EXPOSE_PLANET_GETTER

planet_class.def(
Expand Down
2 changes: 1 addition & 1 deletion pykep/trajopt/_mga.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(
*t0* (:class:`list` [:class:`float` or :class:`~pykep.epoch`]): lower and upper bounds for the launch epoch. When floats are used MJD2000 is assumed.
*tof* (``list`` or ``float``): defines the bounds on the time of flight. If *tof_encoding* is 'direct', this contains a list
*tof* (:class:`list` or :class:`float`): defines the bounds on the time of flight. If *tof_encoding* is 'direct', this contains a list
of 2D lists defining the upper and lower bounds on each leg. If *tof_encoding* is 'alpha',
this contains a 2D list with the lower and upper bounds on the total time-of-flight. If *tof_encoding*
is 'eta' tof is a float defining an upper bound for the time-of-flight.
Expand Down

0 comments on commit b952ff9

Please sign in to comment.