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.
@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.
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.
Hmm, no. I think lambda x: False always gives an empty list.
There was a problem hiding this comment.
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 :-)