Code Duplication    Length = 19-25 lines in 5 locations

aacgmv2/tests/test_py_aacgmv2.py 5 locations

@@ 229-253 (lines=25) @@
226
        np.testing.assert_allclose(self.lon_out, [81.16846959], rtol=1e-4)
227
        np.testing.assert_allclose(self.r_out, [1.04566346], rtol=1e-4)
228
229
    def test_convert_latlon_arr_arr(self):
230
        """Test array latlon conversion for array input"""
231
        (self.lat_out, self.lon_out,
232
         self.r_out) = aacgmv2.convert_latlon_arr(np.array([60, 61]),
233
                                                  np.array([0, 0]),
234
                                                  np.array([300, 300]),
235
                                                  self.dtime)
236
237
        if not isinstance(self.lat_out, np.ndarray):
238
            raise AssertionError()
239
        if not isinstance(self.lon_out, np.ndarray):
240
            raise AssertionError()
241
        if not isinstance(self.r_out, np.ndarray):
242
            raise AssertionError()
243
        if not (self.r_out.shape == self.lon_out.shape and
244
                self.lat_out.shape == self.r_out.shape and
245
                self.r_out.shape == (2,)):
246
            raise AssertionError()
247
248
        np.testing.assert_allclose(self.lat_out, [58.22577090, 59.31860933],
249
                                   rtol=1e-4)
250
        np.testing.assert_allclose(self.lon_out, [81.16846959, 81.61398933],
251
                                   rtol=1e-4)
252
        np.testing.assert_allclose(self.r_out, [1.04566346, 1.04561304],
253
                                   rtol=1e-4)
254
255
    def test_convert_latlon_arr_list_mix(self):
256
        """Test array latlon conversion for mixed types with list"""
@@ 278-300 (lines=23) @@
275
        np.testing.assert_allclose(self.r_out, [1.04566346, 1.04561304],
276
                                   rtol=1e-4)
277
278
    def test_convert_latlon_arr_arr_mix(self):
279
        """Test array latlon conversion for mixed type with an array"""
280
        (self.lat_out, self.lon_out,
281
        self.r_out) = aacgmv2.convert_latlon_arr(np.array([60, 61]), 0,
282
                                                 300, self.dtime)
283
284
        if not isinstance(self.lat_out, np.ndarray):
285
            raise AssertionError()
286
        if not isinstance(self.lon_out, np.ndarray):
287
            raise AssertionError()
288
        if not isinstance(self.r_out, np.ndarray):
289
            raise AssertionError()
290
        if not (self.r_out.shape == self.lon_out.shape and
291
                self.lat_out.shape == self.r_out.shape and
292
                self.r_out.shape == (2,)):
293
            raise AssertionError()
294
295
        np.testing.assert_allclose(self.lat_out, [58.22577090, 59.31860933],
296
                                   rtol=1e-4)
297
        np.testing.assert_allclose(self.lon_out, [81.16846959, 81.61398933],
298
                                   rtol=1e-4)
299
        np.testing.assert_allclose(self.r_out, [1.04566346, 1.04561304],
300
                                   rtol=1e-4)
301
302
    def test_convert_latlon_arr_mult_arr_mix(self):
303
        """Test array latlon conversion for mix type with multi-dim array"""
@@ 184-206 (lines=23) @@
181
        np.testing.assert_allclose(self.lon_out, [81.16846959], rtol=1e-4)
182
        np.testing.assert_allclose(self.r_out, [1.04566346], rtol=1e-4)
183
184
    def test_convert_latlon_arr_list(self):
185
        """Test array latlon conversion for list input"""
186
        (self.lat_out, self.lon_out,
187
         self.r_out) = aacgmv2.convert_latlon_arr([60, 61], [0, 0], [300, 300],
188
                                                  self.dtime)
189
190
        if not isinstance(self.lat_out, np.ndarray):
191
            raise AssertionError()
192
        if not isinstance(self.lon_out, np.ndarray):
193
            raise AssertionError()
194
        if not isinstance(self.r_out, np.ndarray):
195
            raise AssertionError()
196
        if not (self.r_out.shape == self.lon_out.shape and
197
                self.lat_out.shape == self.r_out.shape and
198
                self.r_out.shape == (2,)):
199
            raise AssertionError()
200
201
        np.testing.assert_allclose(self.lat_out, [58.22577090, 59.31860933],
202
                                   rtol=1e-4)
203
        np.testing.assert_allclose(self.lon_out, [81.16846959, 81.61398933],
204
                                   rtol=1e-4)
205
        np.testing.assert_allclose(self.r_out, [1.04566346, 1.04561304],
206
                                   rtol=1e-4)
207
208
    def test_convert_latlon_arr_arr_single(self):
209
        """Test array latlon conversion for array input of shape (1,)"""
@@ 208-227 (lines=20) @@
205
        np.testing.assert_allclose(self.r_out, [1.04566346, 1.04561304],
206
                                   rtol=1e-4)
207
208
    def test_convert_latlon_arr_arr_single(self):
209
        """Test array latlon conversion for array input of shape (1,)"""
210
        (self.lat_out, self.lon_out,
211
        self.r_out) = aacgmv2.convert_latlon_arr(np.array([60]), np.array([0]),
212
                                                 np.array([300]), self.dtime)
213
214
        if not isinstance(self.lat_out, np.ndarray):
215
            raise AssertionError()
216
        if not isinstance(self.lon_out, np.ndarray):
217
            raise AssertionError()
218
        if not isinstance(self.r_out, np.ndarray):
219
            raise AssertionError()
220
        if not (self.r_out.shape == self.lon_out.shape and
221
                self.lat_out.shape == self.r_out.shape and
222
                self.r_out.shape == (1,)):
223
            raise AssertionError()
224
225
        np.testing.assert_allclose(self.lat_out, [58.2257709], rtol=1e-4)
226
        np.testing.assert_allclose(self.lon_out, [81.16846959], rtol=1e-4)
227
        np.testing.assert_allclose(self.r_out, [1.04566346], rtol=1e-4)
228
229
    def test_convert_latlon_arr_arr(self):
230
        """Test array latlon conversion for array input"""
@@ 164-182 (lines=19) @@
161
        np.testing.assert_allclose(self.lon_out, [81.16846959], rtol=1e-4)
162
        np.testing.assert_allclose(self.r_out, [1.04566346], rtol=1e-4)
163
164
    def test_convert_latlon_arr_list_single(self):
165
        """Test array latlon conversion for list input of single values"""
166
        (self.lat_out, self.lon_out,
167
         self.r_out) = aacgmv2.convert_latlon_arr([60], [0], [300], self.dtime)
168
169
        if not isinstance(self.lat_out, np.ndarray):
170
            raise AssertionError()
171
        if not isinstance(self.lon_out, np.ndarray):
172
            raise AssertionError()
173
        if not isinstance(self.r_out, np.ndarray):
174
            raise AssertionError()
175
        if not (self.r_out.shape == self.lon_out.shape and
176
                self.lat_out.shape == self.r_out.shape and
177
                self.r_out.shape == (1,)):
178
            raise AssertionError()
179
180
        np.testing.assert_allclose(self.lat_out, [58.2257709], rtol=1e-4)
181
        np.testing.assert_allclose(self.lon_out, [81.16846959], rtol=1e-4)
182
        np.testing.assert_allclose(self.r_out, [1.04566346], rtol=1e-4)
183
184
    def test_convert_latlon_arr_list(self):
185
        """Test array latlon conversion for list input"""