Skip to content

Commit 618d938

Browse files
authored
Merge 0931867 into fdb4b49
2 parents fdb4b49 + 0931867 commit 618d938

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

lib/iris/coords.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,9 @@ def reindent_data_string(text, n_indent):
573573

574574
def __setattr__(self, key, value):
575575
if getattr(self, "_mesh_timestamps", None) is not None:
576-
for timestamp in self._mesh_timestamps:
577-
timestamp.update()
576+
if key in ("_values_dm", "_values", "_bounds_dm", "points", "bounds"):
577+
for timestamp in self._mesh_timestamps:
578+
timestamp.update()
578579
object.__setattr__(self, key, value)
579580

580581
def __str__(self):

lib/iris/mesh/components.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2828,7 +2828,23 @@ def __getattribute__(self, item):
28282828
# by calling the method on the base class `object`
28292829
updating = object.__getattribute__(self, "_updating")
28302830
if updating is False and item != "update_from_mesh":
2831-
object.__getattribute__(self, "update_from_mesh")()
2831+
# Don't update the points/bounds if you're only getting metadata
2832+
if item not in (
2833+
"_metadata_manager_temp",
2834+
"_metadata_manager",
2835+
"standard_name",
2836+
"long_name",
2837+
"var_name",
2838+
"units",
2839+
"attributes",
2840+
"climatological",
2841+
"coord_system",
2842+
"attributes",
2843+
"haz_lazy_data",
2844+
):
2845+
object.__getattribute__(self, "update_from_mesh")(True)
2846+
else:
2847+
object.__getattribute__(self, "update_from_mesh")(False)
28322848
return super().__getattribute__(item)
28332849

28342850
# Define accessors for MeshCoord-specific properties mesh/location/axis.
@@ -2973,9 +2989,8 @@ def bounds(self, value):
29732989

29742990
@property
29752991
def _metadata_manager(self):
2976-
# sets the metadata
2992+
# update metadata
29772993
use_metadict = self._load_metadata()
2978-
29792994
self._metadata_manager_temp.standard_name = use_metadict["standard_name"]
29802995
self._metadata_manager_temp.long_name = use_metadict["long_name"]
29812996
self._metadata_manager_temp.var_name = use_metadict["var_name"]
@@ -2998,15 +3013,17 @@ def __getitem__(self, keys):
29983013
# Translate "self[:,]" as "self.copy()".
29993014
return self.copy()
30003015

3001-
def update_from_mesh(self):
3016+
def update_from_mesh(self, points_and_bounds=True):
30023017
try:
30033018
object.__setattr__(self, "_updating", True)
30043019
if (self._last_modified is None) or (
30053020
self._last_modified < self.mesh._last_modified
30063021
):
3007-
points, bounds = self._load_points_and_bounds()
3008-
super(MeshCoord, self.__class__).points.fset(self, points)
3009-
super(MeshCoord, self.__class__).bounds.fset(self, bounds)
3022+
if points_and_bounds:
3023+
# update points and bounds
3024+
points, bounds = self._load_points_and_bounds()
3025+
super(MeshCoord, self.__class__).points.fset(self, points)
3026+
super(MeshCoord, self.__class__).bounds.fset(self, bounds)
30103027
object.__setattr__(self, "_last_modified", self.mesh._last_modified)
30113028
# Ensure errors aren't bypassed
30123029
except Exception as e:

0 commit comments

Comments
 (0)