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
Traceback (most recent call last):
File "/home/user/project/src/data/test.py", line 6, in <module>
adata_val, adata_test = train_test_split(adata, test_size=0.5, stratify=adata.obs['Sample Characteristic[cell type]'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.conda/envs/env/lib/python3.12/site-packages/sklearn/utils/_param_validation.py", line 213, in wrapperreturn func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.conda/envs/env/lib/python3.12/site-packages/sklearn/model_selection/_split.py", line 2805, in train_test_splitreturnlist(
^^^^^
File "/home/user/.conda/envs/env/lib/python3.12/site-packages/sklearn/model_selection/_split.py", line 2807, in <genexpr>
(_safe_indexing(a, train), _safe_indexing(a, test)) for a in arrays
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.conda/envs/env/lib/python3.12/site-packages/sklearn/utils/_indexing.py", line 267, in _safe_indexingreturn _array_indexing(X, indices, indices_dtype, axis=axis)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.conda/envs/env/lib/python3.12/site-packages/sklearn/utils/_indexing.py", line 33, in _array_indexingreturn array[key, ...] if axis ==0else array[:, key]
~~~~~^^^^^^^^^^
File "/home/user/.conda/envs/env/lib/python3.12/site-packages/anndata/_core/anndata.py", line 1021, in __getitem__
oidx, vidx =self._normalize_indices(index)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.conda/envs/env/lib/python3.12/site-packages/anndata/_core/anndata.py", line 1002, in _normalize_indicesreturn _normalize_indices(index, self.obs_names, self.var_names)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.conda/envs/env/lib/python3.12/site-packages/anndata/_core/index.py", line 39, in _normalize_indices
ax1 = _normalize_index(ax1, names1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.conda/envs/env/lib/python3.12/site-packages/anndata/_core/index.py", line 109, in _normalize_indexraiseIndexError(f"Unknown indexer {indexer!r} of type {type(indexer)}")
IndexError: Unknown indexer Ellipsis of type <class 'ellipsis'>
ilan-gold
changed the title
Updating sklearn from 1.1.2 to 1.5.1 breaks train_test_split for AnnData because of ellipsis indexing
Support ellipsis indexing
Oct 1, 2024
Please make sure these conditions are met
Report
In 1.5.1 sklearn changed their _array_indexing method to use ellipsis indexing/slicing:
https://github.com/scikit-learn/scikit-learn/blob/1.5.1/sklearn/utils/_indexing.py#L33
Running train_test_split on AnnData now results in an IndexError.
Code:
Traceback:
I'm not sure if this behavior is intended.
Versions
The text was updated successfully, but these errors were encountered: