Skip to content

Commit 1b2347a

Browse files
committed
consider case when all axes chosen
1 parent 555bba0 commit 1b2347a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/iris/coords.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1949,8 +1949,9 @@ def collapsed(self, dims_to_collapse=None):
19491949
# Collapse the coordinate by serializing the points and
19501950
# bounds as strings.
19511951
def serialize(x, axis):
1952-
if axis is None:
1952+
if axis is None or len(axis) == x.ndim:
19531953
return "|".join(str(i) for i in x.flatten())
1954+
19541955
# np.apply_along_axis does not work with str.join, so we
19551956
# need to loop through the array directly. First move (possibly
19561957
# multiple) axis of interest to trailing dim(s), then make a 2D

lib/iris/tests/unit/coords/test_Coord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ def test_string_masked(self):
488488
points = ma.array(["foo", "bar", "bing"], mask=[0, 1, 0], dtype=str)
489489
coord = AuxCoord(points)
490490

491-
collapsed_coord = coord.collapsed()
491+
collapsed_coord = coord.collapsed(0)
492492

493493
expected = "foo|--|bing"
494494
self.assertEqual(collapsed_coord.points, expected)

0 commit comments

Comments
 (0)