larray-project / larray

N-dimensional labelled arrays in Python
https://larray.readthedocs.io/
GNU General Public License v3.0
8 stars 6 forks source link

Deprecate setting values on a view subset #1114

Open gdementen opened 3 months ago

gdementen commented 3 months ago

A subset sometimes sharing its "parent" data is a not-too-rare source of hard-to-find bugs.

We should detect this case and warn this is deprecated:

>>> a = ndtest(3)
>>> b = a[:'a1']
>>> b['a1'] = 0
>>> a['a1']
0

This is a requirement before we can implement #597 and it should preferably be in place for several releases before we implement #597, so this deprecation warning should come as soon as possible.

Sadly, in some cases, this is the best syntax we currently have (combining a single label subset and a boolean filter, see #1084), so it would be nice if we could fix #1084 before this... But I don't think it is worth delaying the warning because our users very rarely need that (and it is broken for multiple labels anyway), while they not-too-rarely stumble on bugs caused by this feature.