MeshCoordMetadata [AVD-1629]#4014
Conversation
Thanks for the catch @pp-mo! |
|
Sorry all -- I failed to include all the changes, at first. |
lib/iris/experimental/ugrid.py
Outdated
| # of lenient metadata services. | ||
| # TODO: when included in 'iris.common.metadata', install each one directly ? | ||
| for cls in (ConnectivityMetadata, MeshCoordMetadata): | ||
| op_names_and_collections = { |
There was a problem hiding this comment.
It might make more sense to define op_names_and_collections outside the loop.
There was a problem hiding this comment.
@pp-mo If you do make convenience variables at the module level, could you also please purge them (del) from the namespace once you've finished using them please 👍
There was a problem hiding this comment.
Just as an afterthought : I'm a bit weak on this...
Would you consider it equivalent to define an __all__, or use only underscore-prefixed things in the package namespace, or is it really that much better to totally tidy it + if so why ?
( I always felt that trying to fix this was somewhat swimming against the tide, given the way that imports mess it all up anyway )
lib/iris/experimental/ugrid.py
Outdated
| A list of different metadata member values. | ||
|
|
||
| """ | ||
| # Perform "strict" difference for "cf_role", "start_index", "src_dim". |
There was a problem hiding this comment.
@pp-mo You just need to update this comment to align it with its members 👍
bjlittle
left a comment
There was a problem hiding this comment.
@pp-mo Awesome stuff! Just a few suggested changes, but LGTM. Great work 😀
We can start using the MeshCoordMetadata in anger to see how it feels, and revisit axis at a later date (soonish) to see what we think about it... plus we may have some actual concrete use case data that helps us weigh up and make an informed decision.
Regardlessly, changing the makeup of the MeshCoordMetadata is a cheap and easy step to take now 👍
🎉 🥳🍻
stephenworsley
left a comment
There was a problem hiding this comment.
Just a couple more comments about the testing along with the existing comments. Otherwise, this looks good!
| def test_op_strict_different(self): | ||
| lmetadata = self.cls(**self.values) | ||
| right = self.values.copy() | ||
| right["long_name"] = self.dummy |
There was a problem hiding this comment.
I feel like it would be more appropriate for this line to be equivalent to this line in test_op_lenient_different
This would reinforce the fact that the reason for the difference in behaviour is due to changing the lenient behaviour and not the choice of value changed.
There was a problem hiding this comment.
Effectively I "inherited" all this from the test_ConnectivityMetadata (except it is really copied of course).
I have now "rationalised" the use of the non-member metadata in these tests : uses of "units" and "var_name" have been replaced with "long_name". I thought that made some sense, as long_name can be just anything whereas units=None would read back as "Unit('unknown')" if using a real object.
| def test_op_strict_different(self): | ||
| lmetadata = self.cls(**self.values) | ||
| right = self.values.copy() | ||
| right["long_name"] = self.dummy |
There was a problem hiding this comment.
Same as above comment.
| left = self.values.copy() | ||
| lmetadata = self.cls(**left) | ||
| right = self.values.copy() | ||
| right["long_name"] = self.dummy |
There was a problem hiding this comment.
Same as above comment.
|
Hoping that latest addresses @bjlittle comments. Ping! Still thinking about @stephenworsley tests changes. |
|
Rebased to fix problem with tests. |
lib/iris/experimental/ugrid.py
Outdated
| #: Convenience collection of lenient metadata difference services. | ||
| SERVICES_DIFFERENCE.append(ConnectivityMetadata.difference) | ||
| SERVICES.append(ConnectivityMetadata.difference) | ||
| _members = ("mesh", "location", "axis") |
There was a problem hiding this comment.
@pp-mo Whoa... are you really suggesting that mesh is metadata here? As in an instance of the forthcoming iris.experimental.ugrid.Mesh ?
This is the payload of the MeshCoord, right? If so, then I really don't agree with this... it's akin to making points and bounds members of the CoordMetadata or DimCoordMetadata, or making the data a member of the CubeMetadata 👎
Or do you intend mesh to be something completely different? 🤔
There was a problem hiding this comment.
Obviously having the actual Mesh as part of the metadata wouldn't work, but given the idea of shared Meshes I'd say some sort of mesh identifier is an important component of the MeshCoord metadata.
There was a problem hiding this comment.
If mesh is a cheap comparison, then yes this could be part of the metadata, but until we know better I think we should err on the side of this not being part the metadata
There was a problem hiding this comment.
Also, __eq__ hasn't been defined within iris.experimental.ugrid.Mesh for this very reason... we're kinda sitting on the fence until we know better
|
Ok, now removed 'mesh' from the metadata, and rebased to accomodate the latest on the mesh-data-model target. |
|
@stephenworsley @bjlittle think we have addressed all previous issues now. |
|
@pp-mo and @stephenworsley LGTM 👍 |
🚀 Pull Request
Description
Adds MeshCoordMetadata class (with tests)
Preliminary to creating a MeshCoord
Note: also fixed some problems I stumbled over in existing metadata testing.
Some of which had already been copied into other tests! ...
There is a lot of boilerplate here :
much of the code in
lib/iris/tests/unit/experimental/ugrid/test_MeshCoordMetadata.pyis a total copyof that in
lib/iris/tests/unit/experimental/ugrid/test_ConnectivityMetadata.py(i.e. ultimately from #3968)As we are in a hurry, we are resolved to fix that "later"...
Consult Iris pull request check list