New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: sparse: Add indexing for 1D arrays #20120
base: main
Are you sure you want to change the base?
Conversation
Move TestGetSet1d to indexing1d.py. Simplify helper functions.
… fix fancy This should set us up for nD indexing when the time comes. Note: ndindex could work for much of this -- but not for sparse array boolean In the future we could maybe implement sparse integer array indexing. We should think about whether 0D return should be sparse array or ndarray. Currently ndarray. This doesn't make reduction functions return sparse arrays yet -- only indexing
I've changed the tests to use np.testing I've also added indexing support for np.newaxis/None (though it can't make 3D+). And that was an excuse to revamp some of the getitem/setitem code to be easier to move to nd. Quanstide's I believe the test failures are not related to this PR. Note: This PR does not change reduction operations to have them return 1D sparse arrays. That will be a separate PR. Note: Another separate PR: We need to decide how to handle 0D. |
Adds support for indexing with 1D arrays.
Builds on #19833 (csr-1d) to provide indexing for 1D CSR arrays, though this code also works for DOK with minor changes after #19715 (dok-1d) gets merged.
The diff will be much easier to read after #19833 is merged. Look at only the last commit to see the diff for just this PR. I will rebase as needed, but I think the CSR PR will be merged soon and the diff here will become cleaner.
test_indexing1d.py
IndexMixin._validate_indices
to use an ndim-independent approach for both 1d and 2d._get_int
,_get_slice
and_get_array
. These are dispatched to after processing the index.self.ndim
. They are_as_indices
and_compatible_boolean_array
.