Skip to content

Commit

Permalink
Fixing long lines
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanwp committed May 1, 2018
1 parent 2ad0b5c commit 861f7c5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
3 changes: 2 additions & 1 deletion lib/iris/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,8 @@ def __getitem__(self, keys):
if bounds is not None:
bounds = bounds.copy()

# The new coordinate is a copy of the old one with replaced content.
# The new coordinate is a copy of the old one with replaced
# content.
new_coord = self.copy(points=points, bounds=bounds)
return new_coord

Expand Down
23 changes: 8 additions & 15 deletions lib/iris/tests/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,27 +313,18 @@ def test_sum(self):
class TestAuxCoordCollapse(tests.IrisTest):

def setUp(self):
from iris.analysis.cartography import area_weights
self.cube_with_aux_coord = tests.stock.simple_4d_with_hybrid_height()

# Guess bounds to get the weights
self.cube_with_aux_coord.coord('grid_latitude').guess_bounds()
self.cube_with_aux_coord.coord('grid_longitude').guess_bounds()

self.weights = area_weights(self.cube_with_aux_coord, normalize=False)
self.normalized_weights = area_weights(self.cube_with_aux_coord, normalize=True)

self.original_alt = self.cube_with_aux_coord.coord('altitude')
# [[100, 101, 102, 103, 104, 105],
# [106, 107, 108, 109, 110, 111],
# [112, 113, 114, 115, 116, 117],
# [118, 119, 120, 121, 122, 123],
# [124, 125, 126, 127, 128, 129]]

def test_max(self):
cube = self.cube_with_aux_coord.collapsed('grid_latitude', iris.analysis.MAX)
cube = self.cube_with_aux_coord.collapsed('grid_latitude',
iris.analysis.MAX)
np.testing.assert_array_equal(cube.coord('surface_altitude').points,
np.array([112, 113, 114, 115, 116, 117]))
np.array([112, 113, 114,
115, 116, 117]))

np.testing.assert_array_equal(cube.coord('surface_altitude').bounds,
np.array([[100, 124],
Expand All @@ -344,15 +335,17 @@ def test_max(self):
[105, 129]]))

# Check collapsing over the whole coord still works
cube = self.cube_with_aux_coord.collapsed('altitude', iris.analysis.MAX)
cube = self.cube_with_aux_coord.collapsed('altitude',
iris.analysis.MAX)

np.testing.assert_array_equal(cube.coord('surface_altitude').points,
np.array([114]))

np.testing.assert_array_equal(cube.coord('surface_altitude').bounds,
np.array([[100, 129]]))

cube = self.cube_with_aux_coord.collapsed('grid_longitude', iris.analysis.MAX)
cube = self.cube_with_aux_coord.collapsed('grid_longitude',
iris.analysis.MAX)

np.testing.assert_array_equal(cube.coord('surface_altitude').points,
np.array([102, 108, 114, 120, 126]))
Expand Down

0 comments on commit 861f7c5

Please sign in to comment.