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

feat[next]: new domain slice syntax #1453

Merged
merged 25 commits into from
Feb 26, 2024

Conversation

nfarabullini
Copy link
Contributor

New domain slice syntax: f[I(-1):I(5)].

E.g. going from:

f[(named_range(I, unit_range(5,10)), ...)]

To:

f[I(5):I(10), ...]

@nfarabullini nfarabullini changed the title edits for indexing feat[next]: new domain slice syntax Feb 14, 2024
@nfarabullini nfarabullini marked this pull request as draft February 14, 2024 13:14
@nfarabullini nfarabullini marked this pull request as ready for review February 14, 2024 16:07
Copy link
Contributor

@havogt havogt left a comment

Choose a reason for hiding this comment

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

Looks good. I have a few comments to improve the structure of the code.

src/gt4py/next/common.py Outdated Show resolved Hide resolved
src/gt4py/next/common.py Outdated Show resolved Hide resolved
src/gt4py/next/embedded/nd_array_field.py Outdated Show resolved Hide resolved
src/gt4py/next/embedded/nd_array_field.py Outdated Show resolved Hide resolved
src/gt4py/next/embedded/nd_array_field.py Outdated Show resolved Hide resolved
src/gt4py/next/embedded/nd_array_field.py Outdated Show resolved Hide resolved
src/gt4py/next/embedded/nd_array_field.py Outdated Show resolved Hide resolved
Copy link
Contributor

@havogt havogt left a comment

Choose a reason for hiding this comment

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

We need to fix the typing for AbsoluteIndexElement, by adding slice to it. The other changes are proposal to improve readability.

src/gt4py/next/embedded/common.py Outdated Show resolved Hide resolved
src/gt4py/next/embedded/common.py Outdated Show resolved Hide resolved
src/gt4py/next/embedded/common.py Outdated Show resolved Hide resolved
src/gt4py/next/common.py Outdated Show resolved Hide resolved
src/gt4py/next/common.py Outdated Show resolved Hide resolved
src/gt4py/next/embedded/common.py Outdated Show resolved Hide resolved
return new_index


def _named_slice_to_named_range(idx: common.NamedSlice) -> common.NamedRange | common.NamedSlice:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def _named_slice_to_named_range(idx: common.NamedSlice) -> common.NamedRange | common.NamedSlice:
def _named_slice_to_named_range(idx: common.NamedSlice) -> common.NamedRange:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically you could just be returning idx without any changes, so you do need common.NamedSlice in the return type

@nfarabullini nfarabullini merged commit 7dea36a into GridTools:main Feb 26, 2024
31 checks passed
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