Code Duplication    Length = 22-24 lines in 2 locations

tests/test_Apex.py 2 locations

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