Code Duplication    Length = 52-53 lines in 2 locations

tests/test_Apex.py 2 locations

@@ 903-955 (lines=53) @@
900
# ============================================================================
901
902
903
def test_map_V_to_height():
904
    apex_out = Apex(date=2000, refh=300)
905
    out_60_15_100_500 = [0.81971957, 2.84512495, 0.69545001]
906
    out_60_15_100_500_234 = [1.83027746, 4.14346436, 0.94764179]
907
    out_60_15_100_1000 = [0.92457698, 3.14997661, 0.85135187]
908
    out_60_15_200_500 = [0.80388262, 2.79321504, 0.68285158]
909
    out_60_30_100_500 = [0.76141245, 2.87884673, 0.73655941]
910
    out_70_15_100_500 = [0.84681866, 2.5925821,  0.34792655]
911
912
    # scalar
913
    assert_allclose(apex_out.map_V_to_height(60, 15, 100, 500, [1, 2, 3]),
914
                    out_60_15_100_500, rtol=1e-5)
915
    assert_allclose(apex_out.map_V_to_height(60, 15, 100, 500, [2, 3, 4]),
916
                    out_60_15_100_500_234, rtol=1e-5)
917
    assert_allclose(apex_out.map_V_to_height(60, 15, 100, 1000, [1, 2, 3]),
918
                    out_60_15_100_1000, rtol=1e-5)
919
    assert_allclose(apex_out.map_V_to_height(60, 15, 200, 500, [1, 2, 3]),
920
                    out_60_15_200_500, rtol=1e-5)
921
    assert_allclose(apex_out.map_V_to_height(60, 30, 100, 500, [1, 2, 3]),
922
                    out_60_30_100_500, rtol=1e-5)
923
    assert_allclose(apex_out.map_V_to_height(70, 15, 100, 500, [1, 2, 3]),
924
                    out_70_15_100_500, rtol=1e-5)
925
926
    # vectorize lat
927
    assert_allclose(apex_out.map_V_to_height([60, 70], 15, 100, 500,
928
                                             np.array([[1, 2, 3]] * 2).T),
929
                    np.array([out_60_15_100_500, out_70_15_100_500]).T,
930
                    rtol=1e-5)
931
932
    # vectorize lon
933
    assert_allclose(apex_out.map_V_to_height(60, [15, 30], 100, 500,
934
                                             np.array([[1, 2, 3]] * 2).T),
935
                    np.array([out_60_15_100_500, out_60_30_100_500]).T,
936
                    rtol=1e-5)
937
938
    # vectorize height
939
    assert_allclose(apex_out.map_V_to_height(60, 15, [100, 200], 500,
940
                                             np.array([[1, 2, 3]] * 2).T),
941
                    np.array([out_60_15_100_500, out_60_15_200_500]).T,
942
                    rtol=1e-5)
943
944
    # vectorize newheight
945
    assert_allclose(apex_out.map_V_to_height(60, 15, 100, [500, 1000],
946
                                             np.array([[1, 2, 3]] * 2).T),
947
                    np.array([out_60_15_100_500, out_60_15_100_1000]).T,
948
                    rtol=1e-5)
949
950
    # vectorize E
951
    assert_allclose(apex_out.map_V_to_height(60, 15, 100, 500,
952
                                             np.array([[1, 2, 3],
953
                                                       [2, 3, 4]]).T),
954
                    np.array([out_60_15_100_500, out_60_15_100_500_234]).T,
955
                    rtol=1e-5)
956
957
958
# ============================================================================
@@ 843-894 (lines=52) @@
840
# ============================================================================
841
842
843
def test_map_E_to_height():
844
    apex_out = Apex(date=2000, refh=300)
845
    out_60_15_100_500 = [0.71152183, 2.35624876, 0.57260784]
846
    out_60_15_100_500_234 = [1.56028502, 3.43916636, 0.78235384]
847
    out_60_15_100_1000 = [0.67796492, 2.08982134, 0.55860785]
848
    out_60_15_200_500 = [0.72377397, 2.42737471, 0.59083726]
849
    out_60_30_100_500 = [0.68626344, 2.37530133, 0.60060124]
850
    out_70_15_100_500 = [0.72760378, 2.18082305, 0.29141979]
851
852
    # scalar
853
    assert_allclose(apex_out.map_E_to_height(60, 15, 100, 500, [1, 2, 3]),
854
                    out_60_15_100_500, rtol=1e-5)
855
    assert_allclose(apex_out.map_E_to_height(60, 15, 100, 500, [2, 3, 4]),
856
                    out_60_15_100_500_234, rtol=1e-5)
857
    assert_allclose(apex_out.map_E_to_height(60, 15, 100, 1000, [1, 2, 3]),
858
                    out_60_15_100_1000, rtol=1e-5)
859
    assert_allclose(apex_out.map_E_to_height(60, 15, 200, 500, [1, 2, 3]),
860
                    out_60_15_200_500, rtol=1e-5)
861
    assert_allclose(apex_out.map_E_to_height(60, 30, 100, 500, [1, 2, 3]),
862
                    out_60_30_100_500, rtol=1e-5)
863
    assert_allclose(apex_out.map_E_to_height(70, 15, 100, 500, [1, 2, 3]),
864
                    out_70_15_100_500, rtol=1e-5)
865
866
    # vectorize lat
867
    assert_allclose(apex_out.map_E_to_height([60, 70], 15, 100, 500,
868
                                             np.array([[1, 2, 3]] * 2).T),
869
                    np.array([out_60_15_100_500, out_70_15_100_500]).T,
870
                    rtol=1e-5)
871
872
    # vectorize lon
873
    assert_allclose(apex_out.map_E_to_height(60, [15, 30], 100, 500,
874
                                             np.array([[1, 2, 3]] * 2).T),
875
                    np.array([out_60_15_100_500, out_60_30_100_500]).T,
876
                    rtol=1e-5)
877
878
    # vectorize height
879
    assert_allclose(apex_out.map_E_to_height(60, 15, [100, 200], 500,
880
                                             np.array([[1, 2, 3]] * 2).T),
881
                    np.array([out_60_15_100_500, out_60_15_200_500]).T,
882
                    rtol=1e-5)
883
884
    # vectorize newheight
885
    assert_allclose(apex_out.map_E_to_height(60, 15, 100, [500, 1000],
886
                                             np.array([[1, 2, 3]] * 2).T),
887
                    np.array([out_60_15_100_500, out_60_15_100_1000]).T,
888
                    rtol=1e-5)
889
890
    # vectorize E
891
    assert_allclose(apex_out.map_E_to_height(60, 15, 100, 500,
892
                                             np.array([[1, 2, 3],
893
                                                       [2, 3, 4]]).T),
894
                    np.array([out_60_15_100_500, out_60_15_100_500_234]).T,
895
                    rtol=1e-5)
896
897