Skip to content

Commit f7784e0

Browse files
committed
remove dubious check; reorder tests
1 parent 7214fec commit f7784e0

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

lib/iris/coords.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,7 +2205,7 @@ def collapsed(self, dims_to_collapse=None):
22052205
# Collapse the coordinate by serializing the points and
22062206
# bounds as strings.
22072207
def serialize(x, axis):
2208-
if axis is None or len(axis) == x.ndim:
2208+
if axis is None:
22092209
return "|".join(str(i) for i in x.flatten())
22102210

22112211
# np.apply_along_axis does not work with str.join, so we
@@ -2214,7 +2214,9 @@ def serialize(x, axis):
22142214
# array we can loop through.
22152215
work_array = np.moveaxis(x, axis, range(-len(axis), 0))
22162216
out_shape = work_array.shape[: -len(axis)]
2217-
work_array = work_array.reshape(np.prod(out_shape), -1)
2217+
work_array = work_array.reshape(
2218+
np.prod(out_shape, dtype=int), -1
2219+
)
22182220

22192221
joined = []
22202222
for arr_slice in work_array:

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,15 @@ def test_lazy_3_bounds(self):
568568
collapsed_coord.bounds, da.array([[0.0, 4.0]])
569569
)
570570

571+
def test_string_masked(self):
572+
points = ma.array(["foo", "bar", "bing"], mask=[0, 1, 0], dtype=str)
573+
coord = AuxCoord(points)
574+
575+
collapsed_coord = coord.collapsed(0)
576+
577+
expected = "foo|--|bing"
578+
self.assertEqual(collapsed_coord.points, expected)
579+
571580
def test_string_nd_first(self):
572581
self.setupTestArrays((3, 4))
573582
coord = AuxCoord(self.pts_real.astype(str))
@@ -582,15 +591,6 @@ def test_string_nd_first(self):
582591

583592
self.assertArrayEqual(collapsed_coord.points, expected)
584593

585-
def test_string_masked(self):
586-
points = ma.array(["foo", "bar", "bing"], mask=[0, 1, 0], dtype=str)
587-
coord = AuxCoord(points)
588-
589-
collapsed_coord = coord.collapsed(0)
590-
591-
expected = "foo|--|bing"
592-
self.assertEqual(collapsed_coord.points, expected)
593-
594594
def test_string_nd_second(self):
595595
self.setupTestArrays((3, 4))
596596
coord = AuxCoord(self.pts_real.astype(str))

0 commit comments

Comments
 (0)