Skip to content
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

Make AxesArray handle slicing correctly #451

Merged
merged 64 commits into from
Jan 31, 2024
Merged
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
e92360f
TST: Add tests for proper AxesArray warnings/slices
Jacob-Stevens-Haas Apr 25, 2023
47e8793
WIP making array slicing consistent
Jacob-Stevens-Haas Apr 26, 2023
647e6ec
WIP: Offload AxesArray construction logic to _AxisMapping
Jacob-Stevens-Haas Apr 30, 2023
06c5b9a
WIP Allow __array_function__ to let ufuncs pass through without change.
Jacob-Stevens-Haas Apr 30, 2023
218e1f4
WIP: begin __getitem__ work to id axes
Jacob-Stevens-Haas May 1, 2023
0d358de
ENH: add function to standardize basic indexing keys
Jacob-Stevens-Haas May 18, 2023
3393599
ENH: rename AxisMapping.reduce and apply to multiple axes
Jacob-Stevens-Haas May 21, 2023
6f6aec5
TST: Add test for inserting axes & mis-ordered axes
Jacob-Stevens-Haas May 21, 2023
a138e05
BUG: build insert_axis
Jacob-Stevens-Haas May 22, 2023
d5e046b
BUG: Allow reduce_axis to handle twisted axes.
Jacob-Stevens-Haas May 22, 2023
86c2e3d
ENH: Enable basic indexing on AxesArrays
Jacob-Stevens-Haas May 22, 2023
478cf52
TST: Build test for standardizing fancy indexers
Jacob-Stevens-Haas May 22, 2023
beef4a7
ENH: Allow _standardize_indexer to handle fancy indexes
Jacob-Stevens-Haas May 22, 2023
5397edc
BUG: make _standardize_indexer handle lists with numpy arrays
Jacob-Stevens-Haas May 23, 2023
353c9d3
TST: enhance advanced indexing test
Jacob-Stevens-Haas May 23, 2023
fb9e01a
TST: Enhance basic slicing test
Jacob-Stevens-Haas Jun 3, 2023
0acda3b
WIP: rearrange __getitem__ for advanced
Jacob-Stevens-Haas May 23, 2023
a54e684
WIP but not at a stable point
Jacob-Stevens-Haas Jun 3, 2023
6ccba03
CLN: Make AxesArray syntax a little clearer
Jacob-Stevens-Haas Jan 4, 2024
b8c8739
BUG: Sort axis argument when inserting or removing axes
Jacob-Stevens-Haas Jan 4, 2024
17842da
BUG: Fix everything about _squeeze_to_sublist with tests
Jacob-Stevens-Haas Jan 4, 2024
efbfac2
CLN: explain _standardize_indexer
Jacob-Stevens-Haas Jan 4, 2024
c101a5a
TST: Test _determine_adv_broadcasting
Jacob-Stevens-Haas Jan 4, 2024
4ac044f
CLN: Remove name mangling from AxesArray _ax_map
Jacob-Stevens-Haas Jan 4, 2024
48634df
CLN: Simplify advanced indexing broadcast calculation
Jacob-Stevens-Haas Jan 4, 2024
91064dd
CLN: Extract function on the basic indexing
Jacob-Stevens-Haas Jan 4, 2024
700521a
CLN: Type the return of determine_adv_broadcasting
Jacob-Stevens-Haas Jan 4, 2024
204223f
ENH: Enable fancy indexing in AxesArray
Jacob-Stevens-Haas Jan 4, 2024
49ac5a0
TST: Update tests for new helper function values
Jacob-Stevens-Haas Jan 4, 2024
42088a1
ENH: Enable boolean advanced indexing in AxesArray
Jacob-Stevens-Haas Jan 5, 2024
62d12ea
ENH: Allow inserting axes by adding strings to index
Jacob-Stevens-Haas Jan 5, 2024
341f15c
CLN: Remove default name for a new axis
Jacob-Stevens-Haas Jan 5, 2024
0ae9f6a
CLN: Remove default name for a new axis
Jacob-Stevens-Haas Jan 6, 2024
80452a6
CLN: Remove unused type expressions
Jacob-Stevens-Haas Jan 7, 2024
51bae67
bug(axes): Only pre-standardize tuple indexers
Jacob-Stevens-Haas Jan 12, 2024
23817f0
feat(_AxisMapping): create an ndim property
Jacob-Stevens-Haas Jan 12, 2024
c11c0d6
bug(axes): enable 0-degree arrays
Jacob-Stevens-Haas Jan 12, 2024
bb1c73d
feat(axes): Enable np.reshape on AxesArrays
Jacob-Stevens-Haas Jan 13, 2024
0bd7182
Merge branch 'master' into axesarray-indexing
Jacob-Stevens-Haas Jan 13, 2024
f13d593
bug: Make caller more explicit to create AxesArray
Jacob-Stevens-Haas Jan 13, 2024
996d555
feat(axes): Make np.transpose work on AxesArray
Jacob-Stevens-Haas Jan 13, 2024
3298f5f
feat(axes): Make np.einsum work on AxesArray
Jacob-Stevens-Haas Jan 14, 2024
18d449e
bug: clean up callers of AxesArray
Jacob-Stevens-Haas Jan 14, 2024
a30220a
Merge remote-tracking branch 'origin/master' into axesarray-indexing
Jacob-Stevens-Haas Jan 14, 2024
cc6025e
feat(axes): Support numpy.ix_
Jacob-Stevens-Haas Jan 14, 2024
f5b2015
bug: Make axes explicit in PDEs
Jacob-Stevens-Haas Jan 14, 2024
e0eb87e
fix(axes): Prevent inf recursive einsum
Jacob-Stevens-Haas Jan 14, 2024
c93ca16
feat(axes): Add np.linalg.solve
Jacob-Stevens-Haas Jan 14, 2024
690aa06
bug: Enable AxesArray in FiniteDifference internals
Jacob-Stevens-Haas Jan 15, 2024
264f8b3
bug(axes): Fix transpose and einsum bugs
Jacob-Stevens-Haas Jan 15, 2024
f0fc6b3
fix(axes): Pass correct ndim to _AxisMapping()
Jacob-Stevens-Haas Jan 15, 2024
8084fd4
feat(axes): Add tensordot function for AxesArrays
Jacob-Stevens-Haas Jan 15, 2024
8f1e4bc
test(axes): Add linalg.solve() tests for AxesArray
Jacob-Stevens-Haas Jan 15, 2024
3dacb89
bug(axes) Change axis alignment linalg_solve + test
Jacob-Stevens-Haas Jan 15, 2024
21c3b01
test(axes): Add tensordot tests
Jacob-Stevens-Haas Jan 15, 2024
36ae58c
fix(axes): pass ts-to-einsum tests
Jacob-Stevens-Haas Jan 16, 2024
730a582
fix(einsum): Replace lstrip with removeprefix in renaming axes
Jacob-Stevens-Haas Jan 16, 2024
93f14a7
bug(finite_difference): Wrap internal arrays as AxesArrays
Jacob-Stevens-Haas Jan 16, 2024
323d115
bug(AxesArray.tensordot): Adapt int index to list of lists
Jacob-Stevens-Haas Jan 16, 2024
cef7167
clean: downgrade typing syntax and stdlibrary use to python 3.8
Jacob-Stevens-Haas Jan 16, 2024
2c56053
doc: Fix doc build errors. Upgrade sphinx
Jacob-Stevens-Haas Jan 17, 2024
3ede6d0
feat/doc(axes): Make helpers public so docs pick them up
Jacob-Stevens-Haas Jan 17, 2024
9c76e79
tst(axes): Cover more lines!
Jacob-Stevens-Haas Jan 17, 2024
bc3fbd2
Merge branch 'master' into axesarray-indexing
Jacob-Stevens-Haas Jan 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(axes): Support numpy.ix_
Jacob-Stevens-Haas committed Jan 14, 2024
commit cc6025e663bc7edcba2befa57667ba6031417e63
14 changes: 14 additions & 0 deletions pysindy/utils/axes.py
Original file line number Diff line number Diff line change
@@ -188,6 +188,12 @@ class AxesArray(np.lib.mixins.NDArrayOperatorsMixin, np.ndarray):
* ``np.reshape``
* ``np.transpose``

Indexing:
AxesArray supports all of the basic and advanced indexing of numpy
arrays, with the addition that new axes can be inserted with a string
name for the axis. If ``None`` or ``np.newaxis`` are passed, the
axis is named "unk".

Parameters:
input_array: the data to create the array.
axes: A dictionary of axis labels to shape indices. Axes labels must
@@ -366,6 +372,14 @@ def decorator(func):
return decorator


@implements(np.ix_)
def ix_(*args: AxesArray):
calc = np.ix_(*(np.asarray(arg) for arg in args))
ax_names = [list(arr.axes)[0] for arr in args]
axes = _AxisMapping.fwd_from_names(ax_names)
return tuple(AxesArray(arr, axes) for arr in calc)


@implements(np.concatenate)
def concatenate(arrays, axis=0, out=None, dtype=None, casting="same_kind"):
parents = [np.asarray(obj) for obj in arrays]