Skip to content

Commit 1efe839

Browse files
committed
consider case when all axes chosen
1 parent 1401e66 commit 1efe839

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lib/iris/coords.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1952,8 +1952,9 @@ def collapsed(self, dims_to_collapse=None):
19521952
# Collapse the coordinate by serializing the points and
19531953
# bounds as strings.
19541954
def serialize(x, axis):
1955-
if axis is None:
1955+
if axis is None or len(axis) == x.ndim:
19561956
return "|".join(str(i) for i in x.flatten())
1957+
19571958
# np.apply_along_axis does not work with str.join, so we
19581959
# need to loop through the array directly. First move (possibly
19591960
# multiple) axis of interest to trailing dim(s), then make a 2D

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

+1-1
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)