Skip to content

Make MeshCoords immutable and sync updates with the attached mesh #6405

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

Merged
merged 26 commits into from
Jul 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
eba7376
initial commit
ESadek-MO Apr 9, 2025
3673c72
corrected indentation
ESadek-MO Apr 9, 2025
9defd00
Merge branch 'main' of github.com:SciTools/iris into functional_times…
ESadek-MO May 12, 2025
323e931
fixed indents
ESadek-MO May 19, 2025
fd8cafa
Made changes to base coords. Tests are being strange locally. Pushing…
ESadek-MO Jun 17, 2025
10ff0cc
add __getattribute__ handling, and fixed SOME tests
ESadek-MO Jun 19, 2025
ad9f997
added try finally, and some more test changes
ESadek-MO Jun 20, 2025
3f2c95c
sorted lazy repr
ESadek-MO Jun 23, 2025
5d2bbaa
all passing tests. Still stuff to do though
ESadek-MO Jun 23, 2025
cd3165d
removed faulty tests, refactored writeablepointsandbounds, other smal…
ESadek-MO Jun 24, 2025
3e5104f
added update function
ESadek-MO Jun 24, 2025
835de97
loadsa stuff
ESadek-MO Jun 27, 2025
7b34bca
review comments and tests
ESadek-MO Jul 1, 2025
2145b3d
find_by_axis
ESadek-MO Jul 1, 2025
2616ba8
removed unit check in test_basic_metadata
ESadek-MO Jul 1, 2025
31f29dc
converted my tests, and all in test_MeshCoord, to pytest
ESadek-MO Jul 1, 2025
f236a9f
corrected conversion errors
ESadek-MO Jul 1, 2025
a69e967
turned timestamps into a class
ESadek-MO Jul 2, 2025
724a038
review comments
ESadek-MO Jul 2, 2025
e013db2
whatsnew
ESadek-MO Jul 2, 2025
e86e340
review comments
ESadek-MO Jul 2, 2025
0f1019d
whatsnew
ESadek-MO Jul 2, 2025
9508ab8
Merge branch 'main' into functional_timestamps
ESadek-MO Jul 2, 2025
85275a6
changed prop to attr in whatsnew
ESadek-MO Jul 2, 2025
a04acd1
review comments
ESadek-MO Jul 3, 2025
3997560
review comment
ESadek-MO Jul 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ This document explains the changes made to Iris for this release
now preserved when it was not previously. See also: :ref:`load-problems`.
(:pull:`6465`, :pull:`6529`)

#. `@ESadek-MO`_ made MeshCoords immutable. :class:`iris.MeshCoord`s are now updated automatically when
changing the attached mesh. All changes to the :class:`iris.MeshCoord` should instead be done to
the relevant :class:`iris.Coord` located on the attached :class:`iris.MeshXY`. This change also affects
the behaviour when calling :attr:`iris.MeshCoord.points` and :attr:`MeshCoord.bounds`, which will return
real data but will leave the :class:`iris.MeshCoord` (and attached mesh) lazy. (:issue:`4757`, :pull:`6405`)


🐛 Bugs Fixed
=============
Expand Down
8 changes: 8 additions & 0 deletions lib/iris/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def __init__(
if not hasattr(self, "_metadata_manager"):
self._metadata_manager = metadata_manager_factory(BaseMetadata)

self._mesh_timestamps = []

#: CF standard name of the quantity that the metadata represents.
self.standard_name = standard_name

Expand Down Expand Up @@ -569,6 +571,12 @@ def reindent_data_string(text, n_indent):

return "\n".join(output_lines)

def __setattr__(self, key, value):
if getattr(self, "_mesh_timestamps", None) is not None:
for timestamp in self._mesh_timestamps:
timestamp.update()
object.__setattr__(self, key, value)

def __str__(self):
return self.summary()

Expand Down
Loading
Loading