Skip to content

Commit

Permalink
Support indices in Shape.only()
Browse files Browse the repository at this point in the history
  • Loading branch information
holl- committed Feb 8, 2024
1 parent 741e7fc commit 2249df6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions phiml/math/_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,10 @@ def only(self, dims: 'DimFilter', reorder=False):
if isinstance(dims, Shape):
dims = dims.names
if isinstance(dims, (tuple, list, set)):
if all(isinstance(d, int) for d in dims):
if not reorder:
dims = tuple(sorted(dims))
return self[dims]
dim_names = []
for d in dims:
if callable(d):
Expand Down

0 comments on commit 2249df6

Please sign in to comment.