Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ This document explains the changes made to Iris for this release
one cell's bounds align with the requested maximum and negative minimum, fixing
:issue:`4221`. (:pull:`4278`)

#. `@tinyendian`_ fixed the error message produced by :meth:`~iris.cube.CubeList.concatenate_cube`
when a cube list contains cubes with different names, which will no longer report
"Cube names differ: var1 != var1" if var1 appears multiple times in the list
(:issue:`4342`, :pull:`4345`)

💣 Incompatible Changes
=======================
Expand Down
4 changes: 3 additions & 1 deletion lib/iris/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,9 @@ def concatenate_cube(
else:
msgs = []
msgs.append(
"Cube names differ: {} != {}".format(names[0], names[1])
"Cube names differ: {} != {}".format(
unique_names[0], unique_names[1]
)
)
raise iris.exceptions.ConcatenateError(msgs)

Expand Down
15 changes: 15 additions & 0 deletions lib/iris/tests/unit/cube/test_CubeList.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,21 @@ def test_fail(self):
with self.assertRaises(iris.exceptions.ConcatenateError):
CubeList([self.cube1, cube2]).concatenate_cube()

def test_names_differ_fail(self):
self.cube2 = Cube([1, 2, 3], "air_temperature", units="K")
self.cube2.add_dim_coord(
DimCoord([3, 4, 5], "time", units=self.units), 0
)
self.cube3 = Cube([1, 2, 3], "air_pressure", units="Pa")
self.cube3.add_dim_coord(
DimCoord([3, 4, 5], "time", units=self.units), 0
)
exc_regexp = "Cube names differ: air_temperature != air_pressure"
with self.assertRaisesRegex(
iris.exceptions.ConcatenateError, exc_regexp
):
CubeList([self.cube1, self.cube2, self.cube3]).concatenate_cube()

def test_empty(self):
exc_regexp = "can't concatenate an empty CubeList"
with self.assertRaisesRegex(ValueError, exc_regexp):
Expand Down