Code Duplication    Length = 19-25 lines in 5 locations

aacgmv2/tests/test_py_aacgmv2.py 5 locations

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