Code Duplication    Length = 33-33 lines in 2 locations

tests/test_Apex.py 2 locations

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