Skip to content

Conversation

@The9Cat
Copy link
Member

@The9Cat The9Cat commented Feb 27, 2025

Summary

This commit overloads CoefStruct::setCoefs() to have two call signatures:

  1. The original version that returns a reference to the CoefStruct data store
  2. A void version that takes as input the flattened array of the same form as CoefStruct::getCoefs() or CoefStruct::setCoefs(); that is, with the signature void CoefStruct::getCoefs(Eigen::VectorXcd& array) and sets the underlying data store from array.

This gets around the confusion of needing to set the values of C from C=CoefStruct::setCoefs() element by element which is a bad use of the numpy API, imho.

Tests

Tested on the 'custom force' notebook from pyEXP-examples/Tutorials/Orbits to confirm that both methods give the same results. This improves the readability the force function in this notebook very nicely! I will check that into EXP-code/pyEXP-examples/#13 if we decide to keep this change.

Notes

This PR adds new minor functionality and, therefore, this addition should not conflict with any current usage pattern and break existing code.

Copy link
Member

@michael-petersen michael-petersen left a comment

Choose a reason for hiding this comment

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

I've been testing this; I really like the new Pythonic interface!

Also good catch on pcaeof.

@michael-petersen michael-petersen merged commit 03caf5e into main Mar 5, 2025
8 checks passed
@The9Cat
Copy link
Member Author

The9Cat commented Mar 5, 2025

Thanks for testing. Yes, hit the 'pcaeof' in doing the halo analysis for dipole. Just an omission...

@The9Cat The9Cat deleted the setCoefs branch March 5, 2025 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants