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

api: Support combination of condition and factor for ConditionalDimension #2413

Merged
merged 2 commits into from
Jul 17, 2024

Conversation

mloubout
Copy link
Contributor

Fixes #2273

@mloubout mloubout added the API api (symbolics, types, ...) label Jul 17, 2024
Copy link

codecov bot commented Jul 17, 2024

Codecov Report

Attention: Patch coverage is 96.22642% with 2 lines in your changes missing coverage. Please review.

Project coverage is 86.72%. Comparing base (0706ced) to head (a112c16).

Files Patch % Lines
devito/types/relational.py 91.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2413   +/-   ##
=======================================
  Coverage   86.72%   86.72%           
=======================================
  Files         235      235           
  Lines       44652    44698   +46     
  Branches     8273     8286   +13     
=======================================
+ Hits        38726    38766   +40     
- Misses       5195     5207   +12     
+ Partials      731      725    -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

# the index will need to be `self.parent - min(self.condition)` to avoid
# shifted indexing. E.g if you have `factor=2` and `condition=Ge(time, 10)`
# then the lowered index needs to be `(time - 10)/ 2`
ltkn = relational_min(self.condition, self.parent)
Copy link
Contributor

Choose a reason for hiding this comment

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

ltkn stands for "left thickness" -- is it really the name u wanna use here?

(nitpicking)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's intentional that the actual left thickness that is required to be shifted by.

@@ -927,7 +942,7 @@ def _arg_defaults(self, _min=None, size=None, alias=None):
# `factor` endpoints are legal, so we return them all. It's then
# up to the caller to decide which one to pick upon reduction
dim = alias or self
if dim._factor is None or size is None:
if dim.condition is not None or size is None:
Copy link
Contributor

Choose a reason for hiding this comment

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

so we don't check _factor anymore here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, basically if there is a condition then you can't safely use the factor to infer arg bounds

@@ -892,6 +895,18 @@ def condition(self):
def indirect(self):
return self._indirect

@property
def fact_index(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you not move this whole logic into __init_finalize__ and set index to the proper value from the get go?

@@ -188,12 +188,19 @@ def __new__(cls, *args, **kwargs):
for d in ordering:
if not d.is_Conditional:
continue
if d.condition is None:
if d._factor is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

why not d.factor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

d.factor is never None it returns 1 if there is no factor for various reasons

Infer the minimum valid value for symbol `s` in the expression `expr`.
For example
- if `expr` is `s < 10`, then the minimum valid value for `s` is 0
- if `expr` is `s >= 10`, then the minimum valid value for `s` is 10
Copy link
Contributor

Choose a reason for hiding this comment

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

or at least this rang a bell when reading the docstring here

@mloubout mloubout merged commit 830a8cf into master Jul 17, 2024
30 of 31 checks passed
@mloubout mloubout deleted the fix-2273 branch July 17, 2024 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API api (symbolics, types, ...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Conflict in time_M when using saved buffer and conditional dimension
3 participants