Skip to content

MeshCoordMetadata [AVD-1629]#4014

Merged
stephenworsley merged 8 commits intoSciTools:mesh-data-modelfrom
pp-mo:meshcoordmeta
Feb 23, 2021
Merged

MeshCoordMetadata [AVD-1629]#4014
stephenworsley merged 8 commits intoSciTools:mesh-data-modelfrom
pp-mo:meshcoordmeta

Conversation

@pp-mo
Copy link
Member

@pp-mo pp-mo commented Feb 17, 2021

🚀 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.py is a total copy
of 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

@pp-mo pp-mo changed the title Fix some problems with existing tests. MeshCoordMetadata Feb 17, 2021
@pp-mo pp-mo requested a review from stephenworsley February 17, 2021 12:19
@pp-mo pp-mo changed the title MeshCoordMetadata MeshCoordMetadata [AVD-1629] Feb 17, 2021
stephenworsley
stephenworsley previously approved these changes Feb 17, 2021
Copy link
Contributor

@stephenworsley stephenworsley left a comment

Choose a reason for hiding this comment

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

Looks good.

@trexfeathers
Copy link
Contributor

Note: also fixed some problems I stumbled over in existing metadata testing.

Thanks for the catch @pp-mo!

@stephenworsley stephenworsley dismissed their stale review February 17, 2021 14:39

Missed additional commits

@pp-mo
Copy link
Member Author

pp-mo commented Feb 17, 2021

Sorry all -- I failed to include all the changes, at first.
Now fixed

# of lenient metadata services.
# TODO: when included in 'iris.common.metadata', install each one directly ?
for cls in (ConnectivityMetadata, MeshCoordMetadata):
op_names_and_collections = {
Copy link
Contributor

Choose a reason for hiding this comment

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

It might make more sense to define op_names_and_collections outside the loop.

Copy link
Member

@bjlittle bjlittle Feb 19, 2021

Choose a reason for hiding this comment

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

@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 👍

Copy link
Member Author

@pp-mo pp-mo Feb 19, 2021

Choose a reason for hiding this comment

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

Awesome spot !
👍

Copy link
Member Author

@pp-mo pp-mo Feb 22, 2021

Choose a reason for hiding this comment

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

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 )

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, I think.

A list of different metadata member values.

"""
# Perform "strict" difference for "cf_role", "start_index", "src_dim".
Copy link
Member

Choose a reason for hiding this comment

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

@pp-mo You just need to update this comment to align it with its members 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 😊

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

Copy link
Member

@bjlittle bjlittle left a comment

Choose a reason for hiding this comment

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

@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 👍

🎉 🥳🍻

Copy link
Contributor

@stephenworsley stephenworsley left a comment

Choose a reason for hiding this comment

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

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
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Member Author

@pp-mo pp-mo Feb 22, 2021

Choose a reason for hiding this comment

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

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
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above comment.

left = self.values.copy()
lmetadata = self.cls(**left)
right = self.values.copy()
right["long_name"] = self.dummy
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above comment.

@pp-mo
Copy link
Member Author

pp-mo commented Feb 22, 2021

Hoping that latest addresses @bjlittle comments. Ping!

Still thinking about @stephenworsley tests changes.
Will respond on that shortly..

@pp-mo
Copy link
Member Author

pp-mo commented Feb 22, 2021

Rebased to fix problem with tests.

#: Convenience collection of lenient metadata difference services.
SERVICES_DIFFERENCE.append(ConnectivityMetadata.difference)
SERVICES.append(ConnectivityMetadata.difference)
_members = ("mesh", "location", "axis")
Copy link
Member

@bjlittle bjlittle Feb 22, 2021

Choose a reason for hiding this comment

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

@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? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok removed it

@pp-mo
Copy link
Member Author

pp-mo commented Feb 23, 2021

Ok, now removed 'mesh' from the metadata, and rebased to accomodate the latest on the mesh-data-model target.
Also tidied up the 'service collections' adjustments, now all handled at the end of 'ugrid.py'

@pp-mo
Copy link
Member Author

pp-mo commented Feb 23, 2021

@stephenworsley @bjlittle think we have addressed all previous issues now.
Sorry about the rebase.
Please re-review !

@bjlittle
Copy link
Member

@pp-mo and @stephenworsley LGTM 👍

@stephenworsley stephenworsley merged commit e719ae0 into SciTools:mesh-data-model Feb 23, 2021
@pp-mo pp-mo deleted the meshcoordmeta branch February 23, 2021 14:06
@trexfeathers trexfeathers mentioned this pull request Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants