So, I know that you can do this by doing
>>> arr[mask] = value
However, if I want to make the code shorter (and not recompute the mask and index each time), I'd like to do something like this:
>>> sub = arr[mask]
>>> sub[...] = value # This works in other cases, but not this one.
My understanding is that doing Ellipses indexing should allow you to specify that you're not reassigning a given variable, but are rather broadcasting to the actual array.
So, here's the question: why doesn't it work?
My thinking is that it's related to the fact that:
>>> arr[mask] is arr[mask]
False
But surely since the mask indexed versions are just views (not copies of the underlying structure), this shouldn't break assignment.
subis a value, it can be change to everything. Sosub = arr[mask]will changesubtoarr[mask](now, sub is a string). Butsub = valuewill changesubtovalue(sub also is a string), it wouldn't changearr[mask]tovalue?sub = arr[mask], I wrotesub[...] = arr[mask]which forces the modification ofsub.