From e935c4efffc5cae1eebbbd6207e66dc35e576625 Mon Sep 17 00:00:00 2001 From: Peter Killick Date: Mon, 9 Oct 2017 15:38:38 +0100 Subject: [PATCH] =?UTF-8?q?Review=20actions=20=E2=80=93=20license=20header?= =?UTF-8?q?,=20py=20version=20compat,=20docstring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/iris/analysis/trajectory.py | 3 +-- .../analysis/trajectory/test_Trajectory.py | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/iris/analysis/trajectory.py b/lib/iris/analysis/trajectory.py index 490a2f3dc78..e885c119956 100644 --- a/lib/iris/analysis/trajectory.py +++ b/lib/iris/analysis/trajectory.py @@ -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 diff --git a/lib/iris/tests/unit/analysis/trajectory/test_Trajectory.py b/lib/iris/tests/unit/analysis/trajectory/test_Trajectory.py index 1119127163d..b57583b3c81 100644 --- a/lib/iris/tests/unit/analysis/trajectory/test_Trajectory.py +++ b/lib/iris/tests/unit/analysis/trajectory/test_Trajectory.py @@ -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. # @@ -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() @@ -84,9 +85,12 @@ 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() @@ -94,11 +98,13 @@ def test_2d(self): 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() @@ -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):