Conversation
for more information, see https://pre-commit.ci
trexfeathers
left a comment
There was a problem hiding this comment.
Thanks @ESadek-MO
I'm confident that you have captured all the manager methods that need to update the timestamp.
Some requests for you
for more information, see https://pre-commit.ci
| def test_mesh_timestamp(self): | ||
| result = self.cube.mesh.timestamp | ||
| self.assertNotNone(result) | ||
|
|
There was a problem hiding this comment.
This is an inappropriate place for testing timestamp - it has no bearing on the functioning of a Cube.
lib/iris/mesh/components.py
Outdated
| @property | ||
| def bounds(self): | ||
| if self.timestamp < self._mesh.timestamp or self.timestamp is None: | ||
| _, self.bounds, _ = self._load_points_and_bounds() | ||
| return super.bounds | ||
|
|
||
| @bounds.setter | ||
| def bounds(self, value): | ||
| if len(value) > 0 and self.bounds: | ||
| msg = "Cannot set 'bounds' on a MeshCoord." | ||
| raise ValueError(msg) |
There was a problem hiding this comment.
These two together create some kind of infinite loop, since the setter accesses the getter then the getter accesses the setter...
Also when I tested this, asking for my_coord.bounds returns None, but perhaps that problem will go away once the above problem is fixed.
| msg = "Cannot yet create a MeshCoord without points." | ||
| raise ValueError(msg) | ||
|
|
||
| # Get the 'coord identity' metadata from the relevant node-coordinate. |
There was a problem hiding this comment.
Something missed in #4757 and in previous discussions: the metadata such as units, standard_name, etcetera is also subject to change.
Thankfully it is quick to recalculate, so we don't need to protect it behind a date check. But we do need a way to make sure it is recalculated on the fly.
Metadata classes a tricksy and it's probably best if we don't make any changes there. Instead we can put self._metadata_manager behind a `@property' so that we can regenerate it every time before returning it:
1
- self._metadata_manager = metadata_manager_factory(MeshCoordMetadata)
+ self._some_other_name = metadata_manager_factory(MeshCoordMetadata)2
@property
def _metadata_manager(self):
# An explanatory comment.
self._some_other_name.standard_name = something
# Etcetera for all standard coord metadata
# THIS INCLUDES DETERMINING THE CORRECT VALUE, AS IN
# THE CURRENT BLOCK WITHIN _load_points_and_bounds
return self._some_other_name3
I don't think this will be necessary since I don't think there will be any calls to set self._metadata_manager?
@_metadata_manager.setter
def _metadata_manager(self, value):
self._some_other_name = valuefor more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
|
This PR was old, out of date and rather difficult to debug, so I've refreshed it in #6405 |
🚀 Pull Request
Closes #4757.
This pull request aims to make MeshCoords immutable, and when it's corresponding Mesh updates, for the MeshCoord to refresh its Points, Bounds, and Metadata from the Mesh.