Code Duplication    Length = 20-25 lines in 3 locations

aacgmv2/tests/test_py_aacgmv2.py 3 locations

@@ 601-625 (lines=25) @@
598
        np.testing.assert_almost_equal(self.mlon_out, 81.1761, decimal=4)
599
        np.testing.assert_almost_equal(self.mlt_out, 0.1889, decimal=4)
600
601
    def test_get_aacgm_coord_arr_arr(self):
602
        """Test array AACGMV2 calculation for an array"""
603
        (self.mlat_out, self.mlon_out,
604
         self.mlt_out) = aacgmv2.get_aacgm_coord_arr(np.array([60, 61]),
605
                                                     np.array([0, 0]),
606
                                                     np.array([300, 300]),
607
                                                     self.dtime)
608
609
        if not isinstance(self.mlat_out, np.ndarray):
610
            raise AssertionError()
611
        if not isinstance(self.mlon_out, np.ndarray):
612
            raise AssertionError()
613
        if not isinstance(self.mlt_out, np.ndarray):
614
            raise AssertionError()
615
        if not (self.mlt_out.shape == self.mlon_out.shape and
616
                self.mlat_out.shape == self.mlt_out.shape and
617
                self.mlt_out.shape == (2,)):
618
            raise AssertionError()
619
620
        np.testing.assert_allclose(self.mlat_out,
621
                                   [58.22474610, 59.31648007], rtol=1e-4)
622
        np.testing.assert_allclose(self.mlon_out,
623
                                   [81.17611033, 81.62281360], rtol=1e-4)
624
        np.testing.assert_allclose(self.mlt_out,
625
                                   [0.18891995, 0.21870017], rtol=1e-4)
626
627
    def test_get_aacgm_coord_arr_list_mix(self):
628
        """Test array AACGMV2 calculation for a list and floats"""
@@ 554-576 (lines=23) @@
551
        np.testing.assert_allclose(self.mlon_out, [81.17611033], rtol=1e-4)
552
        np.testing.assert_allclose(self.mlt_out, [0.18891995], rtol=1e-4)
553
554
    def test_get_aacgm_coord_arr_list(self):
555
        """Test array AACGMV2 calculation for list input"""
556
        (self.mlat_out, self.mlon_out,
557
         self.mlt_out) = aacgmv2.get_aacgm_coord_arr([60, 61], [0, 0],
558
                                                     [300, 300], self.dtime)
559
560
        if not isinstance(self.mlat_out, np.ndarray):
561
            raise AssertionError()
562
        if not isinstance(self.mlon_out, np.ndarray):
563
            raise AssertionError()
564
        if not isinstance(self.mlt_out, np.ndarray):
565
            raise AssertionError()
566
        if not (self.mlt_out.shape == self.mlon_out.shape and
567
                self.mlat_out.shape == self.mlt_out.shape and
568
                self.mlt_out.shape == (2,)):
569
            raise AssertionError()
570
571
        np.testing.assert_allclose(self.mlat_out,
572
                                   [58.22474610, 59.31648007], rtol=1e-4)
573
        np.testing.assert_allclose(self.mlon_out,
574
                                   [81.17611033, 81.62281360], rtol=1e-4)
575
        np.testing.assert_allclose(self.mlt_out,
576
                                   [0.18891995, 0.21870017], rtol=1e-4)
577
578
    def test_get_aacgm_coord_arr_arr_single(self):
579
        """Test array AACGMV2 calculation for array with a single value"""
@@ 533-552 (lines=20) @@
530
        np.testing.assert_allclose(self.mlon_out, [81.17611033], rtol=1e-4)
531
        np.testing.assert_allclose(self.mlt_out, [0.18891995], rtol=1e-4)
532
533
    def test_get_aacgm_coord_arr_list_single(self):
534
        """Test array AACGMV2 calculation for list input of single values"""
535
        (self.mlat_out, self.mlon_out,
536
         self.mlt_out) = aacgmv2.get_aacgm_coord_arr([60], [0], [300],
537
                                                     self.dtime)
538
539
        if not isinstance(self.mlat_out, np.ndarray):
540
            raise AssertionError()
541
        if not isinstance(self.mlon_out, np.ndarray):
542
            raise AssertionError()
543
        if not isinstance(self.mlt_out, np.ndarray):
544
            raise AssertionError()
545
        if not (self.mlt_out.shape == self.mlon_out.shape and
546
                self.mlat_out.shape == self.mlt_out.shape and
547
                self.mlt_out.shape == (1,)):
548
            raise AssertionError()
549
550
        np.testing.assert_allclose(self.mlat_out, [58.22474610], rtol=1e-4)
551
        np.testing.assert_allclose(self.mlon_out, [81.17611033], rtol=1e-4)
552
        np.testing.assert_allclose(self.mlt_out, [0.18891995], rtol=1e-4)
553
554
    def test_get_aacgm_coord_arr_list(self):
555
        """Test array AACGMV2 calculation for list input"""