Introduce indexing for 1d arrays (using an nd approach)#1
Open
dschult wants to merge 5 commits into
Open
Conversation
stefanv
reviewed
Feb 15, 2024
| idx = np.atleast_1d(idx) | ||
|
|
||
| # broadcast scalar to full 1d | ||
| if issparse(x): |
stefanv
reviewed
Feb 15, 2024
Comment on lines
+375
to
+384
| try: | ||
| ix = next(iter(idx), None) | ||
| for _ in range(max_ndim): | ||
| if isinstance(ix, bool): | ||
| # 1st element is boolean, check the rest | ||
| idx = np.asanyarray(idx) | ||
| if idx.dtype.kind == 'b': | ||
| return idx | ||
| return None | ||
| ix = next(iter(ix), None) |
There was a problem hiding this comment.
z = np.add([[False, True, False], [False, False, False]], False, casting='equiv')
|
np.lib.stride_tricks.as_strided([0], strides=(0, 0), shape=(5000, 5000)) |
|
With dtype: np.lib.stride_tricks.as_strided(np.array([1], dtype=float), strides=(0, 0), shape=(50000, 50000)) |
4f67011 to
92f3364
Compare
58cef49 to
4596915
Compare
dschult
pushed a commit
that referenced
this pull request
Apr 26, 2024
BUG: _qmc.py::_random_oa_lhs produces correlated samples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Turn on indexing for 1d csr_arrays!
This version rewrites
_validate_indicesfrom scratch using an N-D approachadds 1-d sections to getitem and setitem dunders
rewrites _validate_indices with an N-d approach.
Reduce helper functions to one
_compatible_boolean_arraywhich in-lines its helper functions.shorter, more readable, cleaner
also computes the shape of the output of this indexing.
passes all tests
adds 1d test for indexing (and passes those also)
__getitem__and__setitem__are still in the 1d/2d paradigm. Changing those will require changing the methods_get_intXsliceand friends. Probably a rewrite of that is needed for N-D. When to do that?This builds on the
csr-1dbranch, but should work withdok-1dbranch after turning on tests for it.And it should work for the 2d-arrays and matrix classes directly off of main (though test_indexing1d.py won't pass obviously).