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

tests: Add test for using a Constant as a condition in a ConditionalDimension #2512

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

EdCaunt
Copy link
Contributor

@EdCaunt EdCaunt commented Jan 7, 2025

This case is valid but not currently tested. It is useful for creating switches that can be set in Python-land. Example applications include preventing accesses on empty ranks when performing sparse operations on functions defined on subdomains.

Copy link

codecov bot commented Jan 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.28%. Comparing base (6615058) to head (4715350).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2512   +/-   ##
=======================================
  Coverage   87.28%   87.28%           
=======================================
  Files         238      238           
  Lines       45724    45733    +9     
  Branches     4058     4058           
=======================================
+ Hits        39911    39920    +9     
  Misses       5128     5128           
  Partials      685      685           

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

def test_constant_as_condition(self, value):
x = Dimension('x')

c = Constant(name="c", dtype=np.int8, value=value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be a Bool if it's a condition by itself?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually you can enhance the test with a bool as well? Behaviour should be the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But C doesn't have a core bool type? You have to import stdbool.h

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Convention is to use an int iirc

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, int is OK

Copy link
Contributor

Choose a reason for hiding this comment

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

int8 btw is converted into a char


c = Constant(name="c", dtype=np.int8, value=value)
cd = ConditionalDimension(name="cd", parent=x, condition=c)

Copy link
Contributor

Choose a reason for hiding this comment

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

can probably drop this empty line

def test_constant_as_condition(self, value):
x = Dimension('x')

c = Constant(name="c", dtype=np.int8, value=value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually you can enhance the test with a bool as well? Behaviour should be the same?

@EdCaunt EdCaunt force-pushed the constant_condition branch from 1963edf to 909c0e0 Compare January 8, 2025 11:44
@EdCaunt EdCaunt force-pushed the constant_condition branch from 909c0e0 to 4715350 Compare January 8, 2025 13:25
@FabioLuporini FabioLuporini merged commit 18ae4f1 into master Jan 9, 2025
31 checks passed
@FabioLuporini FabioLuporini deleted the constant_condition branch January 9, 2025 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants