Code Duplication    Length = 36-36 lines in 2 locations

tests/test_Apex.py 2 locations

@@ 845-880 (lines=36) @@
842
###============================================================================
843
844
845
def test_map_V_to_height():
846
    A = Apex(date=2000, refh=300)
847
    out_60_15_100_500 = [0.819719, 2.845114, 0.695437]
848
    out_60_15_100_500_234 = [1.830277, 4.14345, 0.947624]
849
    out_60_15_100_1000 = [0.924577, 3.149964, 0.851343]
850
    out_60_15_200_500 = [0.803882, 2.793206, 0.682839]
851
    out_60_30_100_500 = [0.761412, 2.878837, 0.736549]
852
    out_70_15_100_500 = [0.846819, 2.592572, 0.347919]
853
854
    # scalar
855
    assert_allclose(A.map_V_to_height(60, 15, 100, 500, [1, 2, 3]),
856
                    out_60_15_100_500, rtol=1e-5)
857
    assert_allclose(A.map_V_to_height(60, 15, 100, 500, [2, 3, 4]),
858
                    out_60_15_100_500_234, rtol=1e-5)
859
    assert_allclose(A.map_V_to_height(60, 15, 100, 1000, [1, 2, 3]),
860
                    out_60_15_100_1000, rtol=1e-5)
861
    assert_allclose(A.map_V_to_height(60, 15, 200, 500, [1, 2, 3]),
862
                    out_60_15_200_500, rtol=1e-5)
863
    assert_allclose(A.map_V_to_height(60, 30, 100, 500, [1, 2, 3]),
864
                    out_60_30_100_500, rtol=1e-5)
865
    assert_allclose(A.map_V_to_height(70, 15, 100, 500, [1, 2, 3]),
866
                    out_70_15_100_500, rtol=1e-5)
867
868
    # vectorize lat
869
    assert_allclose(A.map_V_to_height([60, 70], 15, 100, 500,
870
                                      np.array([[1, 2, 3]]*2).T),
871
                    np.array([out_60_15_100_500, out_70_15_100_500]).T,
872
                    rtol=1e-5)
873
874
    # vectorize lon
875
    assert_allclose(A.map_V_to_height(60, [15, 30], 100, 500,
876
                                      np.array([[1, 2, 3]]*2).T),
877
                    np.array([out_60_15_100_500, out_60_30_100_500]).T,
878
                    rtol=1e-5)
879
880
    # vectorize height
881
    assert_allclose(A.map_V_to_height(60, 15, [100, 200], 500,
882
                                      np.array([[1, 2, 3]]*2).T),
883
                    np.array([out_60_15_100_500, out_60_15_200_500]).T,
@@ 786-821 (lines=36) @@
783
###============================================================================
784
785
786
def test_map_E_to_height():
787
    A = Apex(date=2000, refh=300)
788
    out_60_15_100_500 = [0.7115211, 2.3562392, 0.57259707]
789
    out_60_15_100_500_234 = [1.560284, 3.439154, 0.782339]
790
    out_60_15_100_1000 = [0.677964, 2.089811, 0.558601]
791
    out_60_15_200_500 = [0.723773, 2.427366, 0.590826]
792
    out_60_30_100_500 = [0.686265, 2.375296, 0.600594]
793
    out_70_15_100_500 = [0.727605, 2.180817, 0.291414]
794
795
    # scalar
796
    assert_allclose(A.map_E_to_height(60, 15, 100, 500, [1, 2, 3]),
797
                    out_60_15_100_500, rtol=1e-5)
798
    assert_allclose(A.map_E_to_height(60, 15, 100, 500, [2, 3, 4]),
799
                    out_60_15_100_500_234, rtol=1e-5)
800
    assert_allclose(A.map_E_to_height(60, 15, 100, 1000, [1, 2, 3]),
801
                    out_60_15_100_1000, rtol=1e-5)
802
    assert_allclose(A.map_E_to_height(60, 15, 200, 500, [1, 2, 3]),
803
                    out_60_15_200_500, rtol=1e-5)
804
    assert_allclose(A.map_E_to_height(60, 30, 100, 500, [1, 2, 3]),
805
                    out_60_30_100_500, rtol=1e-5)
806
    assert_allclose(A.map_E_to_height(70, 15, 100, 500, [1, 2, 3]),
807
                    out_70_15_100_500, rtol=1e-5)
808
809
    # vectorize lat
810
    assert_allclose(A.map_E_to_height([60, 70], 15, 100, 500,
811
                                      np.array([[1, 2, 3]]*2).T),
812
                    np.array([out_60_15_100_500, out_70_15_100_500]).T,
813
                    rtol=1e-5)
814
815
    # vectorize lon
816
    assert_allclose(A.map_E_to_height(60, [15, 30], 100, 500,
817
                                      np.array([[1, 2, 3]]*2).T),
818
                    np.array([out_60_15_100_500, out_60_30_100_500]).T,
819
                    rtol=1e-5)
820
821
    # vectorize height
822
    assert_allclose(A.map_E_to_height(60, 15, [100, 200], 500,
823
                                      np.array([[1, 2, 3]]*2).T),
824
                    np.array([out_60_15_100_500, out_60_15_200_500]).T,