Skip to content

Commit

Permalink
Review actions – license header, py version compat, docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
DPeterK committed Oct 9, 2017
1 parent 2720269 commit e935c4e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
3 changes: 1 addition & 2 deletions lib/iris/analysis/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ def __repr__(self):
def _get_interp_points(self):
"""
Translate `self.sampled_points` to the format expected by the
interpolator. If the CRS of the sample points does not match the CRS
of the cube to interpolate, also transform the points.
interpolator.
Returns:
`self.sampled points` in the format required by
Expand Down
24 changes: 15 additions & 9 deletions lib/iris/tests/unit/analysis/trajectory/test_Trajectory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2016, Met Office
# (C) British Crown Copyright 2016 - 2017, Met Office
#
# This file is part of Iris.
#
Expand Down Expand Up @@ -75,7 +75,8 @@ def test_zigzag(self):

class Test__get_interp_points(tests.IrisTest):
def test_basic(self):
waypoints = [{'lat': 0}, {'lat': 1}]
dim_names = 'lat'
waypoints = [{dim_names: 0}, {dim_names: 1}]
sample_count = 5
trajectory = Trajectory(waypoints, sample_count=sample_count)
result = trajectory._get_interp_points()
Expand All @@ -84,21 +85,26 @@ def test_basic(self):
self.assertEqual(len(result), len(waypoints[0]))
self.assertEqual(len(result[0][1]), sample_count)
self.assertEqual(result[0][1], expected_points)
self.assertEqual(result[0][0], dim_names)

def test_2d(self):
waypoints = [{'lat': 0, 'lon': 0}, {'lat': 1, 'lon': 2}]
dim_names = ['lat', 'lon']
waypoints = [{dim_names[0]: 0, dim_names[1]: 0},
{dim_names[0]: 1, dim_names[1]: 2}]
sample_count = 5
trajectory = Trajectory(waypoints, sample_count=sample_count)
result = trajectory._get_interp_points()

self.assertEqual(len(result), len(waypoints[0]))
self.assertEqual(len(result[0][1]), sample_count)
self.assertEqual(len(result[1][1]), sample_count)
self.assertEqual(result[0][0], 'lat')
self.assertEqual(result[1][0], 'lon')
self.assertIn(result[0][0], dim_names)
self.assertIn(result[1][0], dim_names)

def test_3d(self):
waypoints = [{'y': 0, 'x': 0, 'z': 2}, {'y': 1, 'x': 2, 'z': 10}]
dim_names = ['y', 'x', 'z']
waypoints = [{dim_names[0]: 0, dim_names[1]: 0, dim_names[2]: 2},
{dim_names[0]: 1, dim_names[1]: 2, dim_names[2]: 10}]
sample_count = 5
trajectory = Trajectory(waypoints, sample_count=sample_count)
result = trajectory._get_interp_points()
Expand All @@ -107,9 +113,9 @@ def test_3d(self):
self.assertEqual(len(result[0][1]), sample_count)
self.assertEqual(len(result[1][1]), sample_count)
self.assertEqual(len(result[2][1]), sample_count)
self.assertEqual(result[0][0], 'y')
self.assertEqual(result[1][0], 'x')
self.assertEqual(result[2][0], 'z')
self.assertIn(result[0][0], dim_names)
self.assertIn(result[1][0], dim_names)
self.assertIn(result[2][0], dim_names)


class Test_interpolate(tests.IrisTest):
Expand Down

0 comments on commit e935c4e

Please sign in to comment.