Code Duplication    Length = 52-53 lines in 2 locations

tests/test_Apex.py 2 locations

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