Code Duplication    Length = 33-33 lines in 2 locations

apexpy/tests/test_Apex.py 2 locations

@@ 1801-1833 (lines=33) @@
1798
        del self.apex_out, self.in_lat, self.in_lon, self.in_alt
1799
        return
1800
1801
    @pytest.mark.parametrize("method_name, out_comp",
1802
                             [("geo2apex",
1803
                               (56.25343704223633, 92.04932403564453)),
1804
                              ("apex2geo",
1805
                               (53.84184265136719, -66.93045806884766,
1806
                                3.6222547805664362e-06)),
1807
                              ("geo2qd",
1808
                               (56.82968521118164, 92.04932403564453)),
1809
                              ("apex2qd", (60.498401178276744, 15.0)),
1810
                              ("qd2apex", (59.49138097045895, 15.0))])
1811
    def test_method_scalar_input(self, method_name, out_comp):
1812
        """Test the user method against set values with scalars.
1813
1814
        Parameters
1815
        ----------
1816
        method_name : str
1817
            Apex class method to be tested
1818
        out_comp : tuple of floats
1819
            Expected output values
1820
1821
        """
1822
        # Get the desired methods
1823
        user_method = getattr(self.apex_out, method_name)
1824
1825
        # Get the user output
1826
        user_out = user_method(self.in_lat, self.in_lon, self.in_alt)
1827
1828
        # Evaluate the user output
1829
        np.testing.assert_allclose(user_out, out_comp, rtol=1e-5, atol=1e-5)
1830
1831
        for out_val in user_out:
1832
            assert np.asarray(out_val).shape == (), "output is not a scalar"
1833
        return
1834
1835
    def test_convert_to_mlt(self):
1836
        """Test conversion from mlon to mlt with scalars."""
@@ 687-719 (lines=33) @@
684
        assert str(verr).find(estr) >= 0
685
        return
686
687
    @pytest.mark.parametrize("method_name, out_comp",
688
                             [("geo2apex",
689
                               (55.94841766357422, 94.10684204101562)),
690
                              ("apex2geo",
691
                               (51.476322174072266, -66.22817993164062,
692
                                5.727287771151168e-06)),
693
                              ("geo2qd",
694
                               (56.531288146972656, 94.10684204101562)),
695
                              ("apex2qd", (60.498401178276744, 15.0)),
696
                              ("qd2apex", (59.49138097045895, 15.0))])
697
    def test_method_scalar_input(self, method_name, out_comp):
698
        """Test the user method against set values with scalars.
699
700
        Parameters
701
        ----------
702
        method_name : str
703
            Apex class method to be tested
704
        out_comp : tuple of floats
705
            Expected output values
706
707
        """
708
        # Get the desired methods
709
        user_method = getattr(self.apex_out, method_name)
710
711
        # Get the user output
712
        user_out = user_method(self.in_lat, self.in_lon, self.in_alt)
713
714
        # Evaluate the user output
715
        np.testing.assert_allclose(user_out, out_comp, rtol=1e-5, atol=1e-5)
716
717
        for out_val in user_out:
718
            assert np.asarray(out_val).shape == (), "output is not a scalar"
719
        return
720
721
    @pytest.mark.parametrize("in_coord", ["geo", "apex", "qd"])
722
    @pytest.mark.parametrize("out_coord", ["geo", "apex", "qd"])