Code Duplication    Length = 15-21 lines in 5 locations

aacgmv2/tests/test_py_aacgmv2.py 5 locations

@@ 203-223 (lines=21) @@
200
        np.testing.assert_allclose(self.lon_out, [81.16846959], rtol=1e-4)
201
        np.testing.assert_allclose(self.r_out, [1.04566346], rtol=1e-4)
202
203
    def test_convert_latlon_arr_arr(self):
204
        """Test array latlon conversion for array input"""
205
        (self.lat_out, self.lon_out,
206
         self.r_out) = aacgmv2.convert_latlon_arr(np.array([60, 61]),
207
                                                  np.array([0, 0]),
208
                                                  np.array([300, 300]),
209
                                                  self.dtime)
210
211
        assert isinstance(self.lat_out, np.ndarray)
212
        assert isinstance(self.lon_out, np.ndarray)
213
        assert isinstance(self.r_out, np.ndarray)
214
        assert (self.r_out.shape == self.lon_out.shape and
215
                self.lat_out.shape == self.r_out.shape and
216
                self.r_out.shape == (2,))
217
218
        np.testing.assert_allclose(self.lat_out, [58.22577090, 59.31860933],
219
                                   rtol=1e-4)
220
        np.testing.assert_allclose(self.lon_out, [81.16846959, 81.61398933],
221
                                   rtol=1e-4)
222
        np.testing.assert_allclose(self.r_out, [1.04566346, 1.04561304],
223
                                   rtol=1e-4)
224
225
    def test_convert_latlon_arr_list_mix(self):
226
        """Test array latlon conversion for mixed types with list"""
@@ 243-261 (lines=19) @@
240
        np.testing.assert_allclose(self.r_out, [1.04566346, 1.04561304],
241
                                   rtol=1e-4)
242
243
    def test_convert_latlon_arr_arr_mix(self):
244
        """Test array latlon conversion for mixed type with an array"""
245
        (self.lat_out, self.lon_out,
246
        self.r_out) = aacgmv2.convert_latlon_arr(np.array([60, 61]), 0,
247
                                                 300, self.dtime)
248
249
        assert isinstance(self.lat_out, np.ndarray)
250
        assert isinstance(self.lon_out, np.ndarray)
251
        assert isinstance(self.r_out, np.ndarray)
252
        assert (self.r_out.shape == self.lon_out.shape and
253
                self.lat_out.shape == self.r_out.shape and
254
                self.r_out.shape == (2,))
255
256
        np.testing.assert_allclose(self.lat_out, [58.22577090, 59.31860933],
257
                                   rtol=1e-4)
258
        np.testing.assert_allclose(self.lon_out, [81.16846959, 81.61398933],
259
                                   rtol=1e-4)
260
        np.testing.assert_allclose(self.r_out, [1.04566346, 1.04561304],
261
                                   rtol=1e-4)
262
263
    def test_convert_latlon_arr_mult_arr_mix(self):
264
        """Test array latlon conversion for mix type with multi-dim array"""
@@ 166-184 (lines=19) @@
163
        np.testing.assert_allclose(self.lon_out, [81.16846959], rtol=1e-4)
164
        np.testing.assert_allclose(self.r_out, [1.04566346], rtol=1e-4)
165
166
    def test_convert_latlon_arr_list(self):
167
        """Test array latlon conversion for list input"""
168
        (self.lat_out, self.lon_out,
169
         self.r_out) = aacgmv2.convert_latlon_arr([60, 61], [0, 0], [300, 300],
170
                                                  self.dtime)
171
172
        assert isinstance(self.lat_out, np.ndarray)
173
        assert isinstance(self.lon_out, np.ndarray)
174
        assert isinstance(self.r_out, np.ndarray)
175
        assert (self.r_out.shape == self.lon_out.shape and
176
                self.lat_out.shape == self.r_out.shape and
177
                self.r_out.shape == (2,))
178
179
        np.testing.assert_allclose(self.lat_out, [58.22577090, 59.31860933],
180
                                   rtol=1e-4)
181
        np.testing.assert_allclose(self.lon_out, [81.16846959, 81.61398933],
182
                                   rtol=1e-4)
183
        np.testing.assert_allclose(self.r_out, [1.04566346, 1.04561304],
184
                                   rtol=1e-4)
185
186
    def test_convert_latlon_arr_arr_single(self):
187
        """Test array latlon conversion for array input of shape (1,)"""
@@ 186-201 (lines=16) @@
183
        np.testing.assert_allclose(self.r_out, [1.04566346, 1.04561304],
184
                                   rtol=1e-4)
185
186
    def test_convert_latlon_arr_arr_single(self):
187
        """Test array latlon conversion for array input of shape (1,)"""
188
        (self.lat_out, self.lon_out,
189
        self.r_out) = aacgmv2.convert_latlon_arr(np.array([60]), np.array([0]),
190
                                                 np.array([300]), self.dtime)
191
192
        assert isinstance(self.lat_out, np.ndarray)
193
        assert isinstance(self.lon_out, np.ndarray)
194
        assert isinstance(self.r_out, np.ndarray)
195
        assert (self.r_out.shape == self.lon_out.shape and
196
                self.lat_out.shape == self.r_out.shape and
197
                self.r_out.shape == (1,))
198
199
        np.testing.assert_allclose(self.lat_out, [58.2257709], rtol=1e-4)
200
        np.testing.assert_allclose(self.lon_out, [81.16846959], rtol=1e-4)
201
        np.testing.assert_allclose(self.r_out, [1.04566346], rtol=1e-4)
202
203
    def test_convert_latlon_arr_arr(self):
204
        """Test array latlon conversion for array input"""
@@ 150-164 (lines=15) @@
147
        np.testing.assert_allclose(self.lon_out, [81.16846959], rtol=1e-4)
148
        np.testing.assert_allclose(self.r_out, [1.04566346], rtol=1e-4)
149
150
    def test_convert_latlon_arr_list_single(self):
151
        """Test array latlon conversion for list input of single values"""
152
        (self.lat_out, self.lon_out,
153
         self.r_out) = aacgmv2.convert_latlon_arr([60], [0], [300], self.dtime)
154
155
        assert isinstance(self.lat_out, np.ndarray)
156
        assert isinstance(self.lon_out, np.ndarray)
157
        assert isinstance(self.r_out, np.ndarray)
158
        assert (self.r_out.shape == self.lon_out.shape and
159
                self.lat_out.shape == self.r_out.shape and
160
                self.r_out.shape == (1,))
161
162
        np.testing.assert_allclose(self.lat_out, [58.2257709], rtol=1e-4)
163
        np.testing.assert_allclose(self.lon_out, [81.16846959], rtol=1e-4)
164
        np.testing.assert_allclose(self.r_out, [1.04566346], rtol=1e-4)
165
166
    def test_convert_latlon_arr_list(self):
167
        """Test array latlon conversion for list input"""