Code Duplication    Length = 19-25 lines in 5 locations

aacgmv2/tests/test_py_aacgmv2.py 5 locations

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