-
Notifications
You must be signed in to change notification settings - Fork 54
fext[next]: concat_where fieldview embedded #2127
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
Draft
havogt
wants to merge
4
commits into
GridTools:main
Choose a base branch
from
havogt:gtir_concat_where_embedded
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4910440
fext[next]: concat_where fieldview embedded
havogt 3ce2ae3
Merge remote-tracking branch 'upstream/main' into gtir_concat_where_e…
havogt c9925d5
Merge remote-tracking branch 'upstream/main' into gtir_concat_where_e…
havogt 13707c3
a few tests, still incomplete
havogt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -107,6 +107,41 @@ def __add__(self, offset: int) -> Connectivity: | |||||
| def __sub__(self, offset: int) -> Connectivity: | ||||||
| return self + (-offset) | ||||||
|
|
||||||
| def __gt__(self, value: core_defs.IntegralScalar) -> Domain: | ||||||
| return Domain(dims=(self,), ranges=(UnitRange(value + 1, Infinity.POSITIVE),)) | ||||||
|
|
||||||
| def __ge__(self, value: core_defs.IntegralScalar) -> Domain: | ||||||
| return Domain(dims=(self,), ranges=(UnitRange(value, Infinity.POSITIVE),)) | ||||||
|
|
||||||
| def __lt__(self, value: core_defs.IntegralScalar) -> Domain: | ||||||
| return Domain(dims=(self,), ranges=(UnitRange(Infinity.NEGATIVE, value),)) | ||||||
|
|
||||||
| def __le__(self, value: core_defs.IntegralScalar) -> Domain: | ||||||
| # TODO add test | ||||||
| return Domain(dims=(self,), ranges=(UnitRange(Infinity.NEGATIVE, value + 1),)) | ||||||
|
|
||||||
| def __eq__(self, value: Dimension | core_defs.IntegralScalar) -> bool | Domain: | ||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| if isinstance(value, Dimension): | ||||||
| return self.value == value.value | ||||||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
??? |
||||||
| elif isinstance(value, core_defs.INTEGRAL_TYPES): | ||||||
| # TODO probably only within valid embedded context? | ||||||
| return Domain(dims=(self,), ranges=(UnitRange(value, value + 1),)) | ||||||
| else: | ||||||
| return False | ||||||
|
|
||||||
| def __ne__(self, value: Dimension | core_defs.IntegralScalar) -> bool | tuple[Domain, Domain]: | ||||||
| # TODO add test | ||||||
| if isinstance(value, Dimension): | ||||||
| return self.value != value.value | ||||||
| elif isinstance(value, core_defs.INTEGRAL_TYPES): | ||||||
| # TODO probably only within valid embedded context? | ||||||
| return ( | ||||||
| Domain(self, UnitRange(Infinity.NEGATIVE, value)), | ||||||
| Domain(self, UnitRange(value + 1, Infinity.POSITIVE)), | ||||||
| ) | ||||||
| else: | ||||||
| return True | ||||||
|
|
||||||
|
|
||||||
| class Infinity(enum.Enum): | ||||||
| """Describes an unbounded `UnitRange`.""" | ||||||
|
|
@@ -498,6 +533,24 @@ def __and__(self, other: Domain) -> Domain: | |||||
| ) | ||||||
| return Domain(dims=broadcast_dims, ranges=intersected_ranges) | ||||||
|
|
||||||
| def __or__(self, other: Domain) -> Domain: | ||||||
| # TODO support arbitrary union of domains | ||||||
| # TODO add tests | ||||||
| if self.ndim > 1 or other.ndim > 1: | ||||||
| raise NotImplementedError("Union of multidimensional domains is not supported.") | ||||||
| if self.ndim == 0: | ||||||
| return other | ||||||
| if other.ndim == 0: | ||||||
| return self | ||||||
| sorted_ = sorted((self, other), key=lambda x: x.ranges[0].start) | ||||||
| if sorted_[0].ranges[0].stop >= sorted_[1].ranges[0].start: | ||||||
| return Domain( | ||||||
| dims=(self.dims[0],), | ||||||
| ranges=(UnitRange(sorted_[0].ranges[0].start, sorted_[1].ranges[0].stop),), | ||||||
| ) | ||||||
| else: | ||||||
| return (sorted_[0], sorted_[1]) | ||||||
|
|
||||||
| @functools.cached_property | ||||||
| def slice_at(self) -> utils.IndexerCallable[slice, Domain]: | ||||||
| """ | ||||||
|
|
||||||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overloads