You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to assign to a WeightedSumView. It works correctly, when the view is not masked, but if it is masked, it does not work. Pseudo code:
v = some_weighted_hist.view()
v.value[:] = [1, 2, 3] # work ok, v.value is now [1, 2, 3]
v[v.value == 2].value[:] = [3] # does not work, v.value is still [1, 2, 3]
I suppose that the masking operation returns a copy instead of a view.
The text was updated successfully, but these errors were encountered:
v.value[v.value == 2] = [3] # ok, v.value is now [1, 3, 3]
I guess this kind of behavior makes sense. The second version calls __setitem__ with the mask, so it knows which cells to update, while the earlier version above first generates a new copy from the mask on which I then call __setitem__.
I wrote a long reply about histograms not supporting masks before realizing you were operating on a view. Yes, this is part of the Python syntax. Slices do not copy, because of the stride and offset arrays in NumPy (or Python MemoryViews, or Eigen, etc...). But selections like the one above do copy; they have to, since stride and offset cannot perform completely arbitrary selections. So in example 1 you select and then set, while in 2 you select and set in the same operation.
I tried to assign to a WeightedSumView. It works correctly, when the view is not masked, but if it is masked, it does not work. Pseudo code:
I suppose that the masking operation returns a copy instead of a view.
The text was updated successfully, but these errors were encountered: