-
Notifications
You must be signed in to change notification settings - Fork 0
add constraint test #1
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
add constraint test #1
Conversation
|
Thanks @bjlittle, looks good! Is is also worth having the negative result using a spurious coord name? So like I can easily add it myself after after merge if you are 👍 |
lib/iris/tests/test_constraints.py
Outdated
| constraint = iris.Constraint(latitude=lambda x: False) | ||
| result = self.slices.extract(constraint) | ||
| self.assertFalse(result) |
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.
@rcomer This is a negative test i.e., the latitude coordinate is not in any of the self.slices CubeList, so the result is empty
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.
Huh. Now I'm confused. Because the pattern is lambda x: False, I assumed it was the other way around. I.e. I thought the constraint was asking for cubes that don't have it, but they all do. Looking at the actual stock.realistic_4d cube, they clearly won't.
< Had a play >
The result is the same whether you say lambda x: True or lambda x: False? 🤯
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.
Hmm, no. I think lambda x: False always gives an empty list.
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.
In [30]: slices.extract(iris.Constraint(grid_latitude=lambda x: False))
Out[30]: []
|
Thanks @bjlittle 😁 |
@rcomer Apologies for dragging my heels on this one... spinning too many plates as usual.
I guess something along the following lines should be sufficient to give a nod to this particular pattern of constrains usage.
Let me know what you think :-)