Code Duplication    Length = 52-53 lines in 2 locations

tests/test_Apex.py 2 locations

@@ 856-908 (lines=53) @@
853
# ============================================================================
854
855
856
def test_map_V_to_height():
857
    apex_out = Apex(date=2000, refh=300)
858
    out_60_15_100_500 = [0.819719, 2.845114, 0.695437]
859
    out_60_15_100_500_234 = [1.830277, 4.14345, 0.947624]
860
    out_60_15_100_1000 = [0.924577, 3.149964, 0.851343]
861
    out_60_15_200_500 = [0.803882, 2.793206, 0.682839]
862
    out_60_30_100_500 = [0.761412, 2.878837, 0.736549]
863
    out_70_15_100_500 = [0.846819, 2.592572, 0.347919]
864
865
    # scalar
866
    assert_allclose(apex_out.map_V_to_height(60, 15, 100, 500, [1, 2, 3]),
867
                    out_60_15_100_500, rtol=1e-5)
868
    assert_allclose(apex_out.map_V_to_height(60, 15, 100, 500, [2, 3, 4]),
869
                    out_60_15_100_500_234, rtol=1e-5)
870
    assert_allclose(apex_out.map_V_to_height(60, 15, 100, 1000, [1, 2, 3]),
871
                    out_60_15_100_1000, rtol=1e-5)
872
    assert_allclose(apex_out.map_V_to_height(60, 15, 200, 500, [1, 2, 3]),
873
                    out_60_15_200_500, rtol=1e-5)
874
    assert_allclose(apex_out.map_V_to_height(60, 30, 100, 500, [1, 2, 3]),
875
                    out_60_30_100_500, rtol=1e-5)
876
    assert_allclose(apex_out.map_V_to_height(70, 15, 100, 500, [1, 2, 3]),
877
                    out_70_15_100_500, rtol=1e-5)
878
879
    # vectorize lat
880
    assert_allclose(apex_out.map_V_to_height([60, 70], 15, 100, 500,
881
                                             np.array([[1, 2, 3]]*2).T),
882
                    np.array([out_60_15_100_500, out_70_15_100_500]).T,
883
                    rtol=1e-5)
884
885
    # vectorize lon
886
    assert_allclose(apex_out.map_V_to_height(60, [15, 30], 100, 500,
887
                                             np.array([[1, 2, 3]]*2).T),
888
                    np.array([out_60_15_100_500, out_60_30_100_500]).T,
889
                    rtol=1e-5)
890
891
    # vectorize height
892
    assert_allclose(apex_out.map_V_to_height(60, 15, [100, 200], 500,
893
                                             np.array([[1, 2, 3]]*2).T),
894
                    np.array([out_60_15_100_500, out_60_15_200_500]).T,
895
                    rtol=1e-5)
896
897
    # vectorize newheight
898
    assert_allclose(apex_out.map_V_to_height(60, 15, 100, [500, 1000],
899
                                             np.array([[1, 2, 3]]*2).T),
900
                    np.array([out_60_15_100_500, out_60_15_100_1000]).T,
901
                    rtol=1e-5)
902
903
    # vectorize E
904
    assert_allclose(apex_out.map_V_to_height(60, 15, 100, 500,
905
                                             np.array([[1, 2, 3],
906
                                                       [2, 3, 4]]).T),
907
                    np.array([out_60_15_100_500, out_60_15_100_500_234]).T,
908
                    rtol=1e-5)
909
910
911
# ============================================================================
@@ 797-848 (lines=52) @@
794
# ============================================================================
795
796
797
def test_map_E_to_height():
798
    apex_out = Apex(date=2000, refh=300)
799
    out_60_15_100_500 = [0.7115211, 2.3562392, 0.57259707]
800
    out_60_15_100_500_234 = [1.560284, 3.439154, 0.782339]
801
    out_60_15_100_1000 = [0.677964, 2.089811, 0.558601]
802
    out_60_15_200_500 = [0.723773, 2.427366, 0.590826]
803
    out_60_30_100_500 = [0.686265, 2.375296, 0.600594]
804
    out_70_15_100_500 = [0.727605, 2.180817, 0.291414]
805
806
    # scalar
807
    assert_allclose(apex_out.map_E_to_height(60, 15, 100, 500, [1, 2, 3]),
808
                    out_60_15_100_500, rtol=1e-5)
809
    assert_allclose(apex_out.map_E_to_height(60, 15, 100, 500, [2, 3, 4]),
810
                    out_60_15_100_500_234, rtol=1e-5)
811
    assert_allclose(apex_out.map_E_to_height(60, 15, 100, 1000, [1, 2, 3]),
812
                    out_60_15_100_1000, rtol=1e-5)
813
    assert_allclose(apex_out.map_E_to_height(60, 15, 200, 500, [1, 2, 3]),
814
                    out_60_15_200_500, rtol=1e-5)
815
    assert_allclose(apex_out.map_E_to_height(60, 30, 100, 500, [1, 2, 3]),
816
                    out_60_30_100_500, rtol=1e-5)
817
    assert_allclose(apex_out.map_E_to_height(70, 15, 100, 500, [1, 2, 3]),
818
                    out_70_15_100_500, rtol=1e-5)
819
820
    # vectorize lat
821
    assert_allclose(apex_out.map_E_to_height([60, 70], 15, 100, 500,
822
                                             np.array([[1, 2, 3]]*2).T),
823
                    np.array([out_60_15_100_500, out_70_15_100_500]).T,
824
                    rtol=1e-5)
825
826
    # vectorize lon
827
    assert_allclose(apex_out.map_E_to_height(60, [15, 30], 100, 500,
828
                                             np.array([[1, 2, 3]]*2).T),
829
                    np.array([out_60_15_100_500, out_60_30_100_500]).T,
830
                    rtol=1e-5)
831
832
    # vectorize height
833
    assert_allclose(apex_out.map_E_to_height(60, 15, [100, 200], 500,
834
                                             np.array([[1, 2, 3]]*2).T),
835
                    np.array([out_60_15_100_500, out_60_15_200_500]).T,
836
                    rtol=1e-5)
837
838
    # vectorize newheight
839
    assert_allclose(apex_out.map_E_to_height(60, 15, 100, [500, 1000],
840
                                             np.array([[1, 2, 3]]*2).T),
841
                    np.array([out_60_15_100_500, out_60_15_100_1000]).T,
842
                    rtol=1e-5)
843
844
    # vectorize E
845
    assert_allclose(apex_out.map_E_to_height(60, 15, 100, 500,
846
                                             np.array([[1, 2, 3], [2, 3, 4]]).T),
847
                    np.array([out_60_15_100_500, out_60_15_100_500_234]).T,
848
                    rtol=1e-5)
849
850
851
# ============================================================================