Skip to content

Commit 5d5d6ae

Browse files
committed
improve apply_along_axis comment
1 parent feb4d60 commit 5d5d6ae

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/iris/coords.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,10 +2119,11 @@ def serialize(x, axis):
21192119
if axis is None:
21202120
return "|".join(str(i) for i in x.flatten())
21212121

2122-
# np.apply_along_axis does not work with str.join, so we
2123-
# need to loop through the array directly. First move (possibly
2124-
# multiple) axis of interest to trailing dim(s), then make a 2D
2125-
# array we can loop through.
2122+
# np.apply_along_axis combined with str.join will truncate strings in
2123+
# some cases (https://github.com/numpy/numpy/issues/8352), so we need to
2124+
# loop through the array directly. First move (possibly multiple) axis
2125+
# of interest to trailing dim(s), then make a 2D array we can loop
2126+
# through.
21262127
work_array = np.moveaxis(x, axis, range(-len(axis), 0))
21272128
out_shape = work_array.shape[: -len(axis)]
21282129
work_array = work_array.reshape(np.prod(out_shape, dtype=int), -1)

0 commit comments

Comments
 (0)