Code Duplication    Length = 20-25 lines in 3 locations

aacgmv2/tests/test_py_aacgmv2.py 3 locations

@@ 654-678 (lines=25) @@
651
        np.testing.assert_almost_equal(self.mlon_out, 81.1761, decimal=4)
652
        np.testing.assert_almost_equal(self.mlt_out, 0.1889, decimal=4)
653
654
    def test_get_aacgm_coord_arr_arr(self):
655
        """Test array AACGMV2 calculation for an array"""
656
        (self.mlat_out, self.mlon_out,
657
         self.mlt_out) = aacgmv2.get_aacgm_coord_arr(np.array([60, 61]),
658
                                                     np.array([0, 0]),
659
                                                     np.array([300, 300]),
660
                                                     self.dtime)
661
662
        if not isinstance(self.mlat_out, np.ndarray):
663
            raise AssertionError()
664
        if not isinstance(self.mlon_out, np.ndarray):
665
            raise AssertionError()
666
        if not isinstance(self.mlt_out, np.ndarray):
667
            raise AssertionError()
668
        if not (self.mlt_out.shape == self.mlon_out.shape and
669
                self.mlat_out.shape == self.mlt_out.shape and
670
                self.mlt_out.shape == (2,)):
671
            raise AssertionError()
672
673
        np.testing.assert_allclose(self.mlat_out,
674
                                   [58.22474610, 59.31648007], rtol=1e-4)
675
        np.testing.assert_allclose(self.mlon_out,
676
                                   [81.17611033, 81.62281360], rtol=1e-4)
677
        np.testing.assert_allclose(self.mlt_out,
678
                                   [0.18891995, 0.21870017], rtol=1e-4)
679
680
    def test_get_aacgm_coord_arr_list_mix(self):
681
        """Test array AACGMV2 calculation for a list and floats"""
@@ 607-629 (lines=23) @@
604
        np.testing.assert_allclose(self.mlon_out, [81.17611033], rtol=1e-4)
605
        np.testing.assert_allclose(self.mlt_out, [0.18891995], rtol=1e-4)
606
607
    def test_get_aacgm_coord_arr_list(self):
608
        """Test array AACGMV2 calculation for list input"""
609
        (self.mlat_out, self.mlon_out,
610
         self.mlt_out) = aacgmv2.get_aacgm_coord_arr([60, 61], [0, 0],
611
                                                     [300, 300], self.dtime)
612
613
        if not isinstance(self.mlat_out, np.ndarray):
614
            raise AssertionError()
615
        if not isinstance(self.mlon_out, np.ndarray):
616
            raise AssertionError()
617
        if not isinstance(self.mlt_out, np.ndarray):
618
            raise AssertionError()
619
        if not (self.mlt_out.shape == self.mlon_out.shape and
620
                self.mlat_out.shape == self.mlt_out.shape and
621
                self.mlt_out.shape == (2,)):
622
            raise AssertionError()
623
624
        np.testing.assert_allclose(self.mlat_out,
625
                                   [58.22474610, 59.31648007], rtol=1e-4)
626
        np.testing.assert_allclose(self.mlon_out,
627
                                   [81.17611033, 81.62281360], rtol=1e-4)
628
        np.testing.assert_allclose(self.mlt_out,
629
                                   [0.18891995, 0.21870017], rtol=1e-4)
630
631
    def test_get_aacgm_coord_arr_arr_single(self):
632
        """Test array AACGMV2 calculation for array with a single value"""
@@ 586-605 (lines=20) @@
583
        np.testing.assert_allclose(self.mlon_out, [81.17611033], rtol=1e-4)
584
        np.testing.assert_allclose(self.mlt_out, [0.18891995], rtol=1e-4)
585
586
    def test_get_aacgm_coord_arr_list_single(self):
587
        """Test array AACGMV2 calculation for list input of single values"""
588
        (self.mlat_out, self.mlon_out,
589
         self.mlt_out) = aacgmv2.get_aacgm_coord_arr([60], [0], [300],
590
                                                     self.dtime)
591
592
        if not isinstance(self.mlat_out, np.ndarray):
593
            raise AssertionError()
594
        if not isinstance(self.mlon_out, np.ndarray):
595
            raise AssertionError()
596
        if not isinstance(self.mlt_out, np.ndarray):
597
            raise AssertionError()
598
        if not (self.mlt_out.shape == self.mlon_out.shape and
599
                self.mlat_out.shape == self.mlt_out.shape and
600
                self.mlt_out.shape == (1,)):
601
            raise AssertionError()
602
603
        np.testing.assert_allclose(self.mlat_out, [58.22474610], rtol=1e-4)
604
        np.testing.assert_allclose(self.mlon_out, [81.17611033], rtol=1e-4)
605
        np.testing.assert_allclose(self.mlt_out, [0.18891995], rtol=1e-4)
606
607
    def test_get_aacgm_coord_arr_list(self):
608
        """Test array AACGMV2 calculation for list input"""