Code Duplication    Length = 19-25 lines in 5 locations

aacgmv2/tests/test_py_aacgmv2.py 5 locations

@@ 202-226 (lines=25) @@
199
        np.testing.assert_allclose(self.lon_out, [81.16846959], rtol=1e-4)
200
        np.testing.assert_allclose(self.r_out, [1.04566346], rtol=1e-4)
201
202
    def test_convert_latlon_arr_arr(self):
203
        """Test array latlon conversion for array input"""
204
        (self.lat_out, self.lon_out,
205
         self.r_out) = aacgmv2.convert_latlon_arr(np.array([60, 61]),
206
                                                  np.array([0, 0]),
207
                                                  np.array([300, 300]),
208
                                                  self.dtime)
209
210
        if not isinstance(self.lat_out, np.ndarray):
211
            raise AssertionError()
212
        if not isinstance(self.lon_out, np.ndarray):
213
            raise AssertionError()
214
        if not isinstance(self.r_out, np.ndarray):
215
            raise AssertionError()
216
        if not (self.r_out.shape == self.lon_out.shape and
217
                self.lat_out.shape == self.r_out.shape and
218
                self.r_out.shape == (2,)):
219
            raise AssertionError()
220
221
        np.testing.assert_allclose(self.lat_out, [58.22577090, 59.31860933],
222
                                   rtol=1e-4)
223
        np.testing.assert_allclose(self.lon_out, [81.16846959, 81.61398933],
224
                                   rtol=1e-4)
225
        np.testing.assert_allclose(self.r_out, [1.04566346, 1.04561304],
226
                                   rtol=1e-4)
227
228
    def test_convert_latlon_arr_list_mix(self):
229
        """Test array latlon conversion for mixed types with list"""
@@ 251-273 (lines=23) @@
248
        np.testing.assert_allclose(self.r_out, [1.04566346, 1.04561304],
249
                                   rtol=1e-4)
250
251
    def test_convert_latlon_arr_arr_mix(self):
252
        """Test array latlon conversion for mixed type with an array"""
253
        (self.lat_out, self.lon_out,
254
        self.r_out) = aacgmv2.convert_latlon_arr(np.array([60, 61]), 0,
255
                                                 300, self.dtime)
256
257
        if not isinstance(self.lat_out, np.ndarray):
258
            raise AssertionError()
259
        if not isinstance(self.lon_out, np.ndarray):
260
            raise AssertionError()
261
        if not isinstance(self.r_out, np.ndarray):
262
            raise AssertionError()
263
        if not (self.r_out.shape == self.lon_out.shape and
264
                self.lat_out.shape == self.r_out.shape and
265
                self.r_out.shape == (2,)):
266
            raise AssertionError()
267
268
        np.testing.assert_allclose(self.lat_out, [58.22577090, 59.31860933],
269
                                   rtol=1e-4)
270
        np.testing.assert_allclose(self.lon_out, [81.16846959, 81.61398933],
271
                                   rtol=1e-4)
272
        np.testing.assert_allclose(self.r_out, [1.04566346, 1.04561304],
273
                                   rtol=1e-4)
274
275
    def test_convert_latlon_arr_mult_arr_mix(self):
276
        """Test array latlon conversion for mix type with multi-dim array"""
@@ 157-179 (lines=23) @@
154
        np.testing.assert_allclose(self.lon_out, [81.16846959], rtol=1e-4)
155
        np.testing.assert_allclose(self.r_out, [1.04566346], rtol=1e-4)
156
157
    def test_convert_latlon_arr_list(self):
158
        """Test array latlon conversion for list input"""
159
        (self.lat_out, self.lon_out,
160
         self.r_out) = aacgmv2.convert_latlon_arr([60, 61], [0, 0], [300, 300],
161
                                                  self.dtime)
162
163
        if not isinstance(self.lat_out, np.ndarray):
164
            raise AssertionError()
165
        if not isinstance(self.lon_out, np.ndarray):
166
            raise AssertionError()
167
        if not isinstance(self.r_out, np.ndarray):
168
            raise AssertionError()
169
        if not (self.r_out.shape == self.lon_out.shape and
170
                self.lat_out.shape == self.r_out.shape and
171
                self.r_out.shape == (2,)):
172
            raise AssertionError()
173
174
        np.testing.assert_allclose(self.lat_out, [58.22577090, 59.31860933],
175
                                   rtol=1e-4)
176
        np.testing.assert_allclose(self.lon_out, [81.16846959, 81.61398933],
177
                                   rtol=1e-4)
178
        np.testing.assert_allclose(self.r_out, [1.04566346, 1.04561304],
179
                                   rtol=1e-4)
180
181
    def test_convert_latlon_arr_arr_single(self):
182
        """Test array latlon conversion for array input of shape (1,)"""
@@ 181-200 (lines=20) @@
178
        np.testing.assert_allclose(self.r_out, [1.04566346, 1.04561304],
179
                                   rtol=1e-4)
180
181
    def test_convert_latlon_arr_arr_single(self):
182
        """Test array latlon conversion for array input of shape (1,)"""
183
        (self.lat_out, self.lon_out,
184
        self.r_out) = aacgmv2.convert_latlon_arr(np.array([60]), np.array([0]),
185
                                                 np.array([300]), self.dtime)
186
187
        if not isinstance(self.lat_out, np.ndarray):
188
            raise AssertionError()
189
        if not isinstance(self.lon_out, np.ndarray):
190
            raise AssertionError()
191
        if not isinstance(self.r_out, np.ndarray):
192
            raise AssertionError()
193
        if not (self.r_out.shape == self.lon_out.shape and
194
                self.lat_out.shape == self.r_out.shape and
195
                self.r_out.shape == (1,)):
196
            raise AssertionError()
197
198
        np.testing.assert_allclose(self.lat_out, [58.2257709], rtol=1e-4)
199
        np.testing.assert_allclose(self.lon_out, [81.16846959], rtol=1e-4)
200
        np.testing.assert_allclose(self.r_out, [1.04566346], rtol=1e-4)
201
202
    def test_convert_latlon_arr_arr(self):
203
        """Test array latlon conversion for array input"""
@@ 137-155 (lines=19) @@
134
        np.testing.assert_allclose(self.lon_out, [81.16846959], rtol=1e-4)
135
        np.testing.assert_allclose(self.r_out, [1.04566346], rtol=1e-4)
136
137
    def test_convert_latlon_arr_list_single(self):
138
        """Test array latlon conversion for list input of single values"""
139
        (self.lat_out, self.lon_out,
140
         self.r_out) = aacgmv2.convert_latlon_arr([60], [0], [300], self.dtime)
141
142
        if not isinstance(self.lat_out, np.ndarray):
143
            raise AssertionError()
144
        if not isinstance(self.lon_out, np.ndarray):
145
            raise AssertionError()
146
        if not isinstance(self.r_out, np.ndarray):
147
            raise AssertionError()
148
        if not (self.r_out.shape == self.lon_out.shape and
149
                self.lat_out.shape == self.r_out.shape and
150
                self.r_out.shape == (1,)):
151
            raise AssertionError()
152
153
        np.testing.assert_allclose(self.lat_out, [58.2257709], rtol=1e-4)
154
        np.testing.assert_allclose(self.lon_out, [81.16846959], rtol=1e-4)
155
        np.testing.assert_allclose(self.r_out, [1.04566346], rtol=1e-4)
156
157
    def test_convert_latlon_arr_list(self):
158
        """Test array latlon conversion for list input"""