Skip to content

Commit e236779

Browse files
committed
slicing loops -= 1
1 parent c2b3295 commit e236779

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lib/iris/coords.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,13 +2135,15 @@ def serialize(x, axis):
21352135

21362136
bounds = None
21372137
if self.has_bounds():
2138-
bounds = []
2139-
for index in range(self.nbounds):
2140-
bounds_slice = np.take(self.bounds, index, axis=-1)
2141-
serialized = serialize(bounds_slice, dims_to_collapse)
2142-
bounds.append(serialized)
2143-
# Make sure bounds dim comes last.
2144-
bounds = np.moveaxis(bounds, 0, -1)
2138+
# Express dims_to_collapse as non-negative integers.
2139+
if dims_to_collapse is None:
2140+
dims_to_collapse = range(self.ndim)
2141+
else:
2142+
dims_to_collapse = tuple(
2143+
dim % self.ndim for dim in dims_to_collapse
2144+
)
2145+
bounds = serialize(self.bounds, dims_to_collapse)
2146+
21452147
points = serialize(self.points, dims_to_collapse)
21462148
# Create the new collapsed coordinate.
21472149
coord = self.copy(points=np.array(points), bounds=bounds)

0 commit comments

Comments
 (0)