Code Duplication    Length = 33-33 lines in 2 locations

apexpy/tests/test_Apex.py 2 locations

@@ 1824-1856 (lines=33) @@
1821
        del self.apex_out, self.in_lat, self.in_lon, self.in_alt
1822
        return
1823
1824
    @pytest.mark.parametrize("method_name, out_comp",
1825
                             [("geo2apex",
1826
                               (56.25343704223633, 92.04932403564453)),
1827
                              ("apex2geo",
1828
                               (53.84184265136719, -66.93045806884766,
1829
                                3.6222547805664362e-06)),
1830
                              ("geo2qd",
1831
                               (56.82968521118164, 92.04932403564453)),
1832
                              ("apex2qd", (60.498401178276744, 15.0)),
1833
                              ("qd2apex", (59.49138097045895, 15.0))])
1834
    def test_method_scalar_input(self, method_name, out_comp):
1835
        """Test the user method against set values with scalars.
1836
1837
        Parameters
1838
        ----------
1839
        method_name : str
1840
            Apex class method to be tested
1841
        out_comp : tuple of floats
1842
            Expected output values
1843
1844
        """
1845
        # Get the desired methods
1846
        user_method = getattr(self.apex_out, method_name)
1847
1848
        # Get the user output
1849
        user_out = user_method(self.in_lat, self.in_lon, self.in_alt)
1850
1851
        # Evaluate the user output
1852
        np.testing.assert_allclose(user_out, out_comp, rtol=1e-5, atol=1e-5)
1853
1854
        for out_val in user_out:
1855
            assert np.asarray(out_val).shape == (), "output is not a scalar"
1856
        return
1857
1858
    def test_convert_to_mlt(self):
1859
        """Test conversion from mlon to mlt with scalars."""
@@ 710-742 (lines=33) @@
707
        assert str(verr).find(estr) >= 0
708
        return
709
710
    @pytest.mark.parametrize("method_name, out_comp",
711
                             [("geo2apex",
712
                               (55.94841766357422, 94.10684204101562)),
713
                              ("apex2geo",
714
                               (51.476322174072266, -66.22817993164062,
715
                                5.727287771151168e-06)),
716
                              ("geo2qd",
717
                               (56.531288146972656, 94.10684204101562)),
718
                              ("apex2qd", (60.498401178276744, 15.0)),
719
                              ("qd2apex", (59.49138097045895, 15.0))])
720
    def test_method_scalar_input(self, method_name, out_comp):
721
        """Test the user method against set values with scalars.
722
723
        Parameters
724
        ----------
725
        method_name : str
726
            Apex class method to be tested
727
        out_comp : tuple of floats
728
            Expected output values
729
730
        """
731
        # Get the desired methods
732
        user_method = getattr(self.apex_out, method_name)
733
734
        # Get the user output
735
        user_out = user_method(self.in_lat, self.in_lon, self.in_alt)
736
737
        # Evaluate the user output
738
        np.testing.assert_allclose(user_out, out_comp, rtol=1e-5, atol=1e-5)
739
740
        for out_val in user_out:
741
            assert np.asarray(out_val).shape == (), "output is not a scalar"
742
        return
743
744
    @pytest.mark.parametrize("in_coord", ["geo", "apex", "qd"])
745
    @pytest.mark.parametrize("out_coord", ["geo", "apex", "qd"])