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.ancil
If 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()
Current
Ensemble.set_ancilrewrites the ancil completely and doesn't preserve what is already there. So this fails:If I'd like to update it I could do something like this (in modern Python):
It would be fine to have
update_ancilmethod of change the behavior of the currentset_anciil.NB. Actually, the current implementation of the
ancilproperty also allows me to do this and change the underlyingens._encilin the way I want, is it intentional?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):