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
{{ message }}
Repository navigation
"IndexError: boolean index did not match indexed array along dimension" when working with subsetted anndata object #699
scanpy==1.4.3 anndata==0.6.21 umap==0.3.9 numpy==1.16.2 scipy==1.3.0 pandas==0.24.2 scikit-learn==0.21.2 statsmodels==0.9.0
/stor/home/ericb123/miniconda3/lib/python3.7/site-packages/scanpy/preprocessing/_simple.py:1120: RuntimeWarning: invalid value encountered in sqrt
scale = np.sqrt(var)
Trying to set attribute `.X` of view, making a copy.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/stor/home/ericb123/miniconda3/lib/python3.7/site-packages/scanpy/preprocessing/_simple.py", line 860, in scale
scale(adata.X, zero_center=zero_center, max_value=max_value, copy=False)
File "/stor/home/ericb123/miniconda3/lib/python3.7/site-packages/scanpy/preprocessing/_simple.py", line 876, in scale
_scale(X, zero_center)
File "/stor/home/ericb123/miniconda3/lib/python3.7/site-packages/scanpy/preprocessing/_simple.py", line 1126, in _scale
scale[scale == 0] = 1e-12
File "/stor/home/ericb123/miniconda3/lib/python3.7/site-packages/anndata/base.py", line 392, in __setitem__
getattr(adata_view, attr_name)[idx] = value
IndexError: boolean index did not match indexed array along dimension 0; dimension is 130 but corresponding boolean dimension is 765
It looks like it's a bug in how we handle views of objects. If you copy the view you get from subsetting, that should give you the result you want, i.e.:
On our side, I think we should change the behavior of ArrayViews so they return np.ndarrays when operations are performed on them. Maybe we need to override __array_ufunc__?
Activity
ivirshup commentedon Jun 22, 2019
It looks like it's a bug in how we handle views of objects. If you copy the view you get from subsetting, that should give you the result you want, i.e.:
On our side, I think we should change the behavior of
ArrayViewsso they returnnp.ndarrayswhen operations are performed on them. Maybe we need to override__array_ufunc__?