Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 5 additions & 1 deletion docs/iris/src/whatsnew/3.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ This document explains the changes made to Iris for this release
Previously, the first tick label would occasionally be duplicated. This also
removes the use of Matplotlib's deprecated ``IndexFormatter``. (:pull:`3857`)

* `@znicholls`_ fixed :meth:`~iris.quickplot._title` to only check ``units.is_time_reference`` if the ``units`` symbol is not used. (:pull:`3902`)
* `@znicholls`_ fixed :meth:`~iris.quickplot._title` to only check
``units.is_time_reference`` if the ``units`` symbol is not used. (:pull:`3902`)

* `@rcomer`_ fixed a bug whereby numpy array type attributes on a cube's
coordinates could prevent printing it. See :issue:`3921`. (:pull:`3922`)

.. _whatsnew 3.0 changes:

Expand Down
17 changes: 7 additions & 10 deletions lib/iris/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2182,23 +2182,20 @@ def _summary_coord_extra(self, coord, indent):
extra = ""
similar_coords = self.coords(coord.name())
if len(similar_coords) > 1:
# Find all the attribute keys
keys = set()
for similar_coord in similar_coords:
keys.update(similar_coord.attributes.keys())
# Look for any attributes that vary
similar_coords.remove(coord)
# Look for any attributes that vary.
vary = set()
attributes = {}
for key in keys:
for key, value in coord.attributes.items():
for similar_coord in similar_coords:
if key not in similar_coord.attributes:
vary.add(key)
break
value = similar_coord.attributes[key]
if attributes.setdefault(key, value) != value:
if not np.array_equal(
similar_coord.attributes[key], value
):
vary.add(key)
break
keys = sorted(vary & set(coord.attributes.keys()))
keys = sorted(vary)
bits = [
"{}={!r}".format(key, coord.attributes[key]) for key in keys
]
Expand Down
10 changes: 10 additions & 0 deletions lib/iris/tests/unit/cube/test_Cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,16 @@ def test_ancillary_variable(self):
)
self.assertEqual(cube.summary(), expected_summary)

def test_similar_coords(self):
coord1 = AuxCoord(
42, long_name="foo", attributes=dict(bar=np.array([2, 5]))
)
coord2 = coord1.copy()
coord2.attributes = dict(bar="baz")
for coord in [coord1, coord2]:
self.cube.add_aux_coord(coord)
self.assertIn("baz", self.cube.summary())


class Test_is_compatible(tests.IrisTest):
def setUp(self):
Expand Down