-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
Current Ensemble.set_ancil rewrites the ancil completely and doesn't preserve what is already there. So this fails:
ens.set_ancil(dict(a=np.linspace(0, 1, n)))
ens.set_ancil(dict(b=np.linspace(1, 2, n)))
assert 'a' in ens.ancilIf I'd like to update it I could do something like this (in modern Python):
ens.set_ancil(ens.ancil | dict(b=np.linspace(1, 2, n)))It would be fine to have update_ancil method of change the behavior of the current set_anciil.
NB. Actually, the current implementation of the ancil property also allows me to do this and change the underlying ens._encil in the way I want, is it intentional?
ens.ancil['b'] = "hello world"I would suggest to change the implementation to produce a shallow copy of the attribute so users do not have an access to the original data (but still could accidentally change content of the underlying numpy arrays):
@property
def ancil(self):
"""Return the ancillary data dictionary"""
return self._ancil.copy()Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed