Code Duplication    Length = 52-53 lines in 2 locations

tests/test_Apex.py 2 locations

@@ 906-958 (lines=53) @@
903
# ============================================================================
904
905
906
def test_map_V_to_height():
907
    apex_out = Apex(date=2000, refh=300)
908
    out_60_15_100_500 = [0.819719, 2.845114, 0.695437]
909
    out_60_15_100_500_234 = [1.830277, 4.14345, 0.947624]
910
    out_60_15_100_1000 = [0.924577, 3.149964, 0.851343]
911
    out_60_15_200_500 = [0.803882, 2.793206, 0.682839]
912
    out_60_30_100_500 = [0.761412, 2.878837, 0.736549]
913
    out_70_15_100_500 = [0.846819, 2.592572, 0.347919]
914
915
    # scalar
916
    assert_allclose(apex_out.map_V_to_height(60, 15, 100, 500, [1, 2, 3]),
917
                    out_60_15_100_500, rtol=1e-5)
918
    assert_allclose(apex_out.map_V_to_height(60, 15, 100, 500, [2, 3, 4]),
919
                    out_60_15_100_500_234, rtol=1e-5)
920
    assert_allclose(apex_out.map_V_to_height(60, 15, 100, 1000, [1, 2, 3]),
921
                    out_60_15_100_1000, rtol=1e-5)
922
    assert_allclose(apex_out.map_V_to_height(60, 15, 200, 500, [1, 2, 3]),
923
                    out_60_15_200_500, rtol=1e-5)
924
    assert_allclose(apex_out.map_V_to_height(60, 30, 100, 500, [1, 2, 3]),
925
                    out_60_30_100_500, rtol=1e-5)
926
    assert_allclose(apex_out.map_V_to_height(70, 15, 100, 500, [1, 2, 3]),
927
                    out_70_15_100_500, rtol=1e-5)
928
929
    # vectorize lat
930
    assert_allclose(apex_out.map_V_to_height([60, 70], 15, 100, 500,
931
                                             np.array([[1, 2, 3]] * 2).T),
932
                    np.array([out_60_15_100_500, out_70_15_100_500]).T,
933
                    rtol=1e-5)
934
935
    # vectorize lon
936
    assert_allclose(apex_out.map_V_to_height(60, [15, 30], 100, 500,
937
                                             np.array([[1, 2, 3]] * 2).T),
938
                    np.array([out_60_15_100_500, out_60_30_100_500]).T,
939
                    rtol=1e-5)
940
941
    # vectorize height
942
    assert_allclose(apex_out.map_V_to_height(60, 15, [100, 200], 500,
943
                                             np.array([[1, 2, 3]] * 2).T),
944
                    np.array([out_60_15_100_500, out_60_15_200_500]).T,
945
                    rtol=1e-5)
946
947
    # vectorize newheight
948
    assert_allclose(apex_out.map_V_to_height(60, 15, 100, [500, 1000],
949
                                             np.array([[1, 2, 3]] * 2).T),
950
                    np.array([out_60_15_100_500, out_60_15_100_1000]).T,
951
                    rtol=1e-5)
952
953
    # vectorize E
954
    assert_allclose(apex_out.map_V_to_height(60, 15, 100, 500,
955
                                             np.array([[1, 2, 3],
956
                                                       [2, 3, 4]]).T),
957
                    np.array([out_60_15_100_500, out_60_15_100_500_234]).T,
958
                    rtol=1e-5)
959
960
961
# ============================================================================
@@ 846-897 (lines=52) @@
843
# ============================================================================
844
845
846
def test_map_E_to_height():
847
    apex_out = Apex(date=2000, refh=300)
848
    out_60_15_100_500 = [0.7115211, 2.3562392, 0.57259707]
849
    out_60_15_100_500_234 = [1.560284, 3.439154, 0.782339]
850
    out_60_15_100_1000 = [0.677964, 2.089811, 0.558601]
851
    out_60_15_200_500 = [0.723773, 2.427366, 0.590826]
852
    out_60_30_100_500 = [0.686265, 2.375296, 0.600594]
853
    out_70_15_100_500 = [0.727605, 2.180817, 0.291414]
854
855
    # scalar
856
    assert_allclose(apex_out.map_E_to_height(60, 15, 100, 500, [1, 2, 3]),
857
                    out_60_15_100_500, rtol=1e-5)
858
    assert_allclose(apex_out.map_E_to_height(60, 15, 100, 500, [2, 3, 4]),
859
                    out_60_15_100_500_234, rtol=1e-5)
860
    assert_allclose(apex_out.map_E_to_height(60, 15, 100, 1000, [1, 2, 3]),
861
                    out_60_15_100_1000, rtol=1e-5)
862
    assert_allclose(apex_out.map_E_to_height(60, 15, 200, 500, [1, 2, 3]),
863
                    out_60_15_200_500, rtol=1e-5)
864
    assert_allclose(apex_out.map_E_to_height(60, 30, 100, 500, [1, 2, 3]),
865
                    out_60_30_100_500, rtol=1e-5)
866
    assert_allclose(apex_out.map_E_to_height(70, 15, 100, 500, [1, 2, 3]),
867
                    out_70_15_100_500, rtol=1e-5)
868
869
    # vectorize lat
870
    assert_allclose(apex_out.map_E_to_height([60, 70], 15, 100, 500,
871
                                             np.array([[1, 2, 3]] * 2).T),
872
                    np.array([out_60_15_100_500, out_70_15_100_500]).T,
873
                    rtol=1e-5)
874
875
    # vectorize lon
876
    assert_allclose(apex_out.map_E_to_height(60, [15, 30], 100, 500,
877
                                             np.array([[1, 2, 3]] * 2).T),
878
                    np.array([out_60_15_100_500, out_60_30_100_500]).T,
879
                    rtol=1e-5)
880
881
    # vectorize height
882
    assert_allclose(apex_out.map_E_to_height(60, 15, [100, 200], 500,
883
                                             np.array([[1, 2, 3]] * 2).T),
884
                    np.array([out_60_15_100_500, out_60_15_200_500]).T,
885
                    rtol=1e-5)
886
887
    # vectorize newheight
888
    assert_allclose(apex_out.map_E_to_height(60, 15, 100, [500, 1000],
889
                                             np.array([[1, 2, 3]] * 2).T),
890
                    np.array([out_60_15_100_500, out_60_15_100_1000]).T,
891
                    rtol=1e-5)
892
893
    # vectorize E
894
    assert_allclose(apex_out.map_E_to_height(60, 15, 100, 500,
895
                                             np.array([[1, 2, 3],
896
                                                       [2, 3, 4]]).T),
897
                    np.array([out_60_15_100_500, out_60_15_100_500_234]).T,
898
                    rtol=1e-5)
899
900