Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/iris/experimental/regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,9 +953,15 @@ def _src_align_and_flatten(coord):
min_sx, min_tx = np.min(sx.points), np.min(tx.points)
if min_sx < 0 and min_tx >= 0:
indices = np.where(sx_points < 0)
# Ensure += doesn't raise a TypeError
if not np.can_cast(modulus, sx_points.dtype):
sx_points = sx_points.astype(type(modulus), casting='safe')
sx_points[indices] += modulus
elif min_sx >= 0 and min_tx < 0:
indices = np.where(sx_points > (modulus / 2))
# Ensure -= doesn't raise a TypeError
if not np.can_cast(modulus, sx_points.dtype):
sx_points = sx_points.astype(type(modulus), casting='safe')
sx_points[indices] -= modulus

# Create target grid cube x and y cell boundaries.
Expand Down
6 changes: 3 additions & 3 deletions lib/iris/tests/unit/analysis/test_WPERCENTILE.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2015, Met Office
# (C) British Crown Copyright 2015 - 2016, Met Office
#
# This file is part of Iris.
#
Expand Down Expand Up @@ -141,7 +141,7 @@ def test_2d_multi(self):
actual = WPERCENTILE.aggregate(data, axis=0, percent=percent,
weights=weights)
self.assertTupleEqual(actual.shape, (shape[-1], percent.size))
expected = np.tile(np.arange(shape[-1]), percent.size)
expected = np.tile(np.arange(shape[-1]), percent.size).astype('f8')
expected = expected.reshape(percent.size, shape[-1]).T
expected[:, 1:-1] += (percent[1:-1]-25)*0.2
expected[:, -1] += 10.
Expand All @@ -156,7 +156,7 @@ def test_masked_2d_multi(self):
actual = WPERCENTILE.aggregate(data, axis=0, percent=percent,
weights=weights)
self.assertTupleEqual(actual.shape, (shape[-1], percent.size))
expected = np.tile(np.arange(shape[-1]), percent.size)
expected = np.tile(np.arange(shape[-1]), percent.size).astype('f8')
expected = expected.reshape(percent.size, shape[-1]).T
expected[:, 1:-1] += (percent[1:-1]-25)*0.4
expected[:, -1] += 20.
Expand Down