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

[InMemoryDataset redesign] ix_with_slices, format_ndindex #387

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

crusaderky
Copy link
Collaborator

@crusaderky crusaderky commented Oct 20, 2024

Two new general purpose functions

Copy link
Collaborator

@peytondmurray peytondmurray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No complaints here - I look forward to seeing how ix_with_slices comes into play in the next PRs :)

Just a few merge conflicts to resolve, then we should merge.

return np.ix_(*idx2)


def format_ndindex(idx: Any) -> str:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Maybe ndindex itself would benefit from implementing something similar for its objects. If that happens, we could just return str(ndindex(idx)) here. Anyway for now this looks good.

return a.astype(dtype)


def ix_with_slices(*idx: Any, shape: tuple[int, ...]) -> tuple:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is really cool. With this you can more elegantly select hyperrectangles of n-dim arrays. Nice!

@asmeurer
Copy link
Collaborator

Both of these things could definitely live in ndindex itself, although it's understandable if you just want to put them here first since ndindex may have more stringent requirements.

@crusaderky crusaderky merged commit 62b8a28 into deshaw:master Oct 22, 2024
8 checks passed
@crusaderky crusaderky deleted the ix_with_slices branch October 22, 2024 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants