Skip to content

Commit 2e889cf

Browse files
committed
consider case when all axes chosen
1 parent cf474b5 commit 2e889cf

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
@@ -2233,8 +2233,9 @@ def collapsed(self, dims_to_collapse=None):
22332233
# Collapse the coordinate by serializing the points and
22342234
# bounds as strings.
22352235
def serialize(x, axis):
2236-
if axis is None:
2236+
if axis is None or len(axis) == x.ndim:
22372237
return "|".join(str(i) for i in x.flatten())
2238+
22382239
# np.apply_along_axis does not work with str.join, so we
22392240
# need to loop through the array directly. First move (possibly
22402241
# 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
@@ -583,7 +583,7 @@ def test_string_masked(self):
583583
points = ma.array(["foo", "bar", "bing"], mask=[0, 1, 0], dtype=str)
584584
coord = AuxCoord(points)
585585

586-
collapsed_coord = coord.collapsed()
586+
collapsed_coord = coord.collapsed(0)
587587

588588
expected = "foo|--|bing"
589589
self.assertEqual(collapsed_coord.points, expected)

0 commit comments

Comments
 (0)