Code Duplication    Length = 22-24 lines in 2 locations

tests/test_Apex.py 2 locations

@@ 218-241 (lines=24) @@
215
                                   fortran_func(*fortran_args)[fslice])
216
        return
217
218
    @pytest.mark.parametrize("apex_method,fortran_method,fslice",
219
                             [("_geo2qd", "apxg2q", slice(0, 2, 1)),
220
                              ("_geo2apex", "apxg2all", slice(2, 4, 1)),
221
                              ("_qd2geo", "apxq2g", slice(None)),
222
                              ("_basevec", "apxg2q", slice(2, 4, 1))])
223
    @pytest.mark.parametrize("lat", [(0), (30), (60), (89)])
224
    @pytest.mark.parametrize("lon1,lon2", [(180, 180), (-180, -180),
225
                                           (180, -180), (-180, 180),
226
                                           (-345, 15), (375, 15)])
227
    def test_fortran_longitude_rollover(self, apex_method, fortran_method,
228
                                        fslice, lat, lon1, lon2):
229
        """Tests Apex/fortran interface consistency for longitude rollover."""
230
        # Get the Apex class method and the fortran function call
231
        apex_func = getattr(self.apex_out, apex_method)
232
        fortran_func = getattr(fa, fortran_method)
233
234
        # Get the appropriate input arguments
235
        apex_args = self.get_input_args(apex_method, lat, lon1, 100)
236
        fortran_args = self.get_input_args(fortran_method, lat, lon2, 100)
237
238
        # Evaluate the equivalent function calls
239
        np.testing.assert_allclose(apex_func(*apex_args),
240
                                   fortran_func(*fortran_args)[fslice])
241
        return
242
243
    @pytest.mark.parametrize("apex_method,fortran_method,fslice",
244
                             [("_geo2qd", "apxg2q", slice(0, 2, 1)),
@@ 195-216 (lines=22) @@
192
193
        return in_args
194
195
    @pytest.mark.parametrize("apex_method,fortran_method,fslice",
196
                             [("_geo2qd", "apxg2q", slice(0, 2, 1)),
197
                              ("_geo2apex", "apxg2all", slice(2, 4, 1)),
198
                              ("_qd2geo", "apxq2g", slice(None)),
199
                              ("_basevec", "apxg2q", slice(2, 4, 1))])
200
    @pytest.mark.parametrize("lat", [(0), (30), (60), (89)])
201
    @pytest.mark.parametrize("lon", [(-179), (-90), (0), (90), (180)])
202
    def test_fortran_scalar_input(self, apex_method, fortran_method, fslice,
203
                                  lat, lon):
204
        """Tests Apex/fortran interface consistency for scalars."""
205
        # Get the Apex class method and the fortran function call
206
        apex_func = getattr(self.apex_out, apex_method)
207
        fortran_func = getattr(fa, fortran_method)
208
209
        # Get the appropriate input arguments
210
        apex_args = self.get_input_args(apex_method, lat, lon, 100)
211
        fortran_args = self.get_input_args(fortran_method, lat, lon, 100)
212
213
        # Evaluate the equivalent function calls
214
        np.testing.assert_allclose(apex_func(*apex_args),
215
                                   fortran_func(*fortran_args)[fslice])
216
        return
217
218
    @pytest.mark.parametrize("apex_method,fortran_method,fslice",
219
                             [("_geo2qd", "apxg2q", slice(0, 2, 1)),