Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PiecewisePolynomial, QuaternionFunctionofTime, and Serialize Pybindings #6336

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

AlexCarpenter46
Copy link
Contributor

Proposed changes

Adds some pybindings necessary for creating volume data with functions of time in python.

Upgrade instructions

Code review checklist

  • The code is documented and the documentation renders correctly. Run
    make doc to generate the documentation locally into BUILD_DIR/docs/html.
    Then open index.html.
  • The code follows the stylistic and code quality guidelines listed in the
    code review guide.
  • The PR lists upgrade instructions and is labeled bugfix or
    new feature if appropriate.

Further comments

@AlexCarpenter46 AlexCarpenter46 added the cli/pybindings Command line interface & Python bindings label Oct 16, 2024
Copy link
Contributor

@knelli2 knelli2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can squash everything in directly. No need for fixups

Comment on lines +39 to +40
std::shared_ptr<domain::FunctionsOfTime::FunctionOfTime>>&
shared_deserialized_functions_of_time) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just call this argument functions_of_time. The fact that it's shared is just a python thing, and they are clearly deserialized (since it's not a vector<char>)

Comment on lines +44 to +45
unique_deserialized_functions_of_time{};
if (shared_deserialized_functions_of_time.contains("Expansion")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just loop over all keys in the input map and call get_clone. No need to get specific names

Comment on lines 80 to +81
py::arg("serialized_functions_of_time"));
py::class_<FunctionsOfTime::PiecewisePolynomial<3>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for organization, move these classes right after the FunctionsOfTime::FunctionOfTime class.

Comment on lines +81 to +83
py::class_<FunctionsOfTime::PiecewisePolynomial<3>,
FunctionsOfTime::FunctionOfTime,
std::shared_ptr<FunctionsOfTime::PiecewisePolynomial<3>>>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the PiecewisePolynomial, let's bind both order 2 and 3. To avoid duplicating code, write a lambda that's templated and call that for 2 and 3 like so

const auto bind_piecewise_polynomial = [&]<size_t Order>() {
  // code that you have now using Order
  // Have each name be "PiecewisePolynomial" + std::to_string(Order)
};

bind_piecewise_polynomial.template operator()<2>();
bind_piecewise_polynomial.template operator()<3>();

(no need to do this for the Quat)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli/pybindings Command line interface & Python bindings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants