-
Notifications
You must be signed in to change notification settings - Fork 54
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
SurfaceRZFourier cache isn't invalidated by setting rc, zs, rs, zc arrays #465
base: master
Are you sure you want to change the base?
SurfaceRZFourier cache isn't invalidated by setting rc, zs, rs, zc arrays #465
Conversation
…n logging messages in Spec class
This reverts commit 7e2afad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice idea!
what about setting splices of rc, zs which is a common use case (on my end at least). Do the set_rc, set_rs function take in ranges as well?
unit tests are needed too
Neither the Technically I believe this could be implemented by overloading the class ObservableArray(np.ndarray):
def __new__(cls, array, callback=None):
obj = np.asarray(array).view(cls)
obj._callback = callback
return obj
# supports slice syntax as well
def __setitem__(self, key, value):
super().__setitem__(key, value)
if self._callback:
self._callback() https://numpy.org/doc/stable/user/basics.subclassing.html#view-casting |
There are not setter properties for the arrays
rc
,zs
,rs
,zc
, sorecompute_bell()
is not triggered by overwriting them (there is of course setter properties for individual elements tho).For example, this means that plots, or depending objective functions aren't updated when overwriting the entire rc array, e.g. to scale a configuration by a constant factor. The following example script will plot the same torus twice, eventho the coefficients were changed (same problem with ).
can now be done with
My suggestion is to either
_rc
and property decorators for the accessorsrc
, but that would also involve changing the CPP class and seems quite invasiveset_zs()
docstring:"""Modifyting the
zsarray directly is discouraged, since it doesn't trigger the recompute_bell(). """