Code Duplication    Length = 20-25 lines in 3 locations

aacgmv2/tests/test_py_aacgmv2.py 3 locations

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