@@ -867,3 +867,159 @@ end
867867@test ! islowercase (' A' )
868868@test uppercasefirst (" qwerty" ) == " Qwerty"
869869@test lowercasefirst (" Qwerty" ) == " qwerty"
870+
871+ # 0.7.0-DEV.4064
872+ # some tests are behind a version check below because Julia gave
873+ # the wrong result between 0.7.0-DEV.3262 and 0.7.0-DEV.4646
874+ # see https://github.com/JuliaLang/julia/issues/26488
875+ Issue26488 = VERSION < v " 0.7.0-DEV.3262" || VERSION >= v " 0.7.0-DEV.4646"
876+ @test Compat. Statistics. mean ([1 2 ; 3 4 ]) == 2.5
877+ @test Compat. Statistics. mean ([1 2 ; 3 4 ], dims= 1 ) == [2 3 ]
878+ @test Compat. Statistics. mean ([1 2 ; 3 4 ], dims= 2 ) == hcat ([1.5 ; 3.5 ])
879+ @test Compat. cumsum ([1 2 ; 3 4 ], dims= 1 ) == [1 2 ; 4 6 ]
880+ @test Compat. cumsum ([1 2 ; 3 4 ], dims= 2 ) == [1 3 ; 3 7 ]
881+ @test Compat. cumprod ([1 2 ; 3 4 ], dims= 1 ) == [1 2 ; 3 8 ]
882+ @test Compat. cumprod ([1 2 ; 3 4 ], dims= 2 ) == [1 2 ; 3 12 ]
883+ @test Compat. sum ([1 2 ; 3 4 ]) == 10
884+ @test Compat. sum ([1 2 ; 3 4 ], dims= 1 ) == [4 6 ]
885+ @test Compat. sum ([1 2 ; 3 4 ], dims= 2 ) == hcat ([3 ; 7 ])
886+ @test Compat. sum (x -> x+ 1 , [1 2 ; 3 4 ]) == 14
887+ Issue26488 && @test Compat. sum (x -> x+ 1 , [1 2 ; 3 4 ], dims= 1 ) == [6 8 ]
888+ Issue26488 && @test Compat. sum (x -> x+ 1 , [1 2 ; 3 4 ], dims= 2 ) == hcat ([5 ; 9 ])
889+ @test Compat. prod ([1 2 ; 3 4 ]) == 24
890+ @test Compat. prod ([1 2 ; 3 4 ], dims= 1 ) == [3 8 ]
891+ @test Compat. prod ([1 2 ; 3 4 ], dims= 2 ) == hcat ([2 ; 12 ])
892+ @test Compat. prod (x -> x+ 1 , [1 2 ; 3 4 ]) == 120
893+ Issue26488 && @test Compat. prod (x -> x+ 1 , [1 2 ; 3 4 ], dims= 1 ) == [8 15 ]
894+ Issue26488 && @test Compat. prod (x -> x+ 1 , [1 2 ; 3 4 ], dims= 2 ) == hcat ([6 ; 20 ])
895+ @test Compat. maximum ([1 2 ; 3 4 ]) == 4
896+ @test Compat. maximum ([1 2 ; 3 4 ], dims= 1 ) == [3 4 ]
897+ @test Compat. maximum ([1 2 ; 3 4 ], dims= 2 ) == hcat ([2 ; 4 ])
898+ @test Compat. maximum (x -> x+ 1 , [1 2 ; 3 4 ]) == 5
899+ @test Compat. maximum (x -> x+ 1 , [1 2 ; 3 4 ], dims= 1 ) == [4 5 ]
900+ @test Compat. maximum (x -> x+ 1 , [1 2 ; 3 4 ], dims= 2 ) == hcat ([3 ; 5 ])
901+ @test Compat. minimum ([1 2 ; 3 4 ]) == 1
902+ @test Compat. minimum ([1 2 ; 3 4 ], dims= 1 ) == [1 2 ]
903+ @test Compat. minimum ([1 2 ; 3 4 ], dims= 2 ) == hcat ([1 ; 3 ])
904+ @test Compat. minimum (x -> x+ 1 , [1 2 ; 3 4 ]) == 2
905+ @test Compat. minimum (x -> x+ 1 , [1 2 ; 3 4 ], dims= 1 ) == [2 3 ]
906+ @test Compat. minimum (x -> x+ 1 , [1 2 ; 3 4 ], dims= 2 ) == hcat ([2 ; 4 ])
907+ @test Compat. all ([true false ; true false ]) == false
908+ @test Compat. all ([true false ; true false ], dims= 1 ) == [true false ]
909+ @test Compat. all ([true false ; true false ], dims= 2 ) == hcat ([false ; false ])
910+ @test Compat. all (isodd, [1 2 ; 3 4 ]) == false
911+ @test Compat. all (isodd, [1 2 ; 3 4 ], dims= 1 ) == [true false ]
912+ @test Compat. all (isodd, [1 2 ; 3 4 ], dims= 2 ) == hcat ([false ; false ])
913+ @test Compat. any ([true false ; true false ]) == true
914+ @test Compat. any ([true false ; true false ], dims= 1 ) == [true false ]
915+ @test Compat. any ([true false ; true false ], dims= 2 ) == hcat ([true ; true ])
916+ @test Compat. any (isodd, [1 2 ; 3 4 ]) == true
917+ @test Compat. any (isodd, [1 2 ; 3 4 ], dims= 1 ) == [true false ]
918+ @test Compat. any (isodd, [1 2 ; 3 4 ], dims= 2 ) == hcat ([true ; true ])
919+ @test Compat. findmax ([3 , 2 , 7 , 4 ]) == (7 , 3 )
920+ @test Compat. findmax ([3 , 2 , 7 , 4 ], dims= 1 ) == ([7 ], [3 ])
921+ @test Compat. findmax ([1 2 ; 3 4 ], dims= 1 ) == ([3 4 ], [CartesianIndex (2 , 1 ) CartesianIndex (2 , 2 )])
922+ @test Compat. findmax ([1 2 ; 3 4 ]) == (4 , CartesianIndex (2 , 2 ))
923+ @test Compat. findmax ([1 2 ; 3 4 ], dims= 1 ) == ([3 4 ], [CartesianIndex (2 , 1 ) CartesianIndex (2 , 2 )])
924+ @test Compat. findmax ([1 2 ; 3 4 ], dims= 2 ) == (hcat ([2 ; 4 ]), hcat ([CartesianIndex (1 , 2 ); CartesianIndex (2 , 2 )]))
925+ @test Compat. findmin ([3 , 2 , 7 , 4 ]) == (2 , 2 )
926+ @test Compat. findmin ([3 , 2 , 7 , 4 ], dims= 1 ) == ([2 ], [2 ])
927+ @test Compat. findmin ([1 2 ; 3 4 ]) == (1 , CartesianIndex (1 , 1 ))
928+ @test Compat. findmin ([1 2 ; 3 4 ], dims= 1 ) == ([1 2 ], [CartesianIndex (1 , 1 ) CartesianIndex (1 , 2 )])
929+ @test Compat. findmin ([1 2 ; 3 4 ], dims= 2 ) == (hcat ([1 ; 3 ]), hcat ([CartesianIndex (1 , 1 ); CartesianIndex (2 , 1 )]))
930+ if VERSION < v " 0.7.0-DEV.5238"
931+ # Test these functions if their counterparts are defined in Base. In the future, this
932+ # will be dealt with in StatsBase
933+ @test Compat. Statistics. varm ([1 2 ; 3 4 ], - 1 ) == 18
934+ @test Compat. Statistics. varm ([1 2 ; 3 4 ], [- 1 - 2 ], dims= 1 ) == [20 52 ]
935+ @test Compat. Statistics. varm ([1 2 ; 3 4 ], [- 1 , - 2 ], dims= 2 ) == hcat ([13 , 61 ])
936+ @test Compat. Statistics. var ([1 2 ; 3 4 ]) == 5 / 3
937+ @test Compat. Statistics. var ([1 2 ; 3 4 ], dims= 1 ) == [2 2 ]
938+ @test Compat. Statistics. var ([1 2 ; 3 4 ], dims= 2 ) == hcat ([0.5 , 0.5 ])
939+ @test Compat. Statistics. var ([1 2 ; 3 4 ], corrected= false ) == 1.25
940+ @test Compat. Statistics. var ([1 2 ; 3 4 ], corrected= false , dims= 1 ) == [1 1 ]
941+ @test Compat. Statistics. var ([1 2 ; 3 4 ], corrected= false , dims= 2 ) == hcat ([0.25 , 0.25 ])
942+ @test Compat. Statistics. std ([1 2 ; 3 4 ]) == sqrt (5 / 3 )
943+ @test Compat. Statistics. std ([1 2 ; 3 4 ], dims= 1 ) == [sqrt (2 ) sqrt (2 )]
944+ @test Compat. Statistics. std ([1 2 ; 3 4 ], dims= 2 ) == hcat ([sqrt (0.5 ), sqrt (0.5 )])
945+ @test Compat. Statistics. std ([1 2 ; 3 4 ], corrected= false ) == sqrt (1.25 )
946+ @test Compat. Statistics. std ([1 2 ; 3 4 ], corrected= false , dims= 1 ) == [sqrt (1 ) sqrt (1 )]
947+ @test Compat. Statistics. std ([1 2 ; 3 4 ], corrected= false , dims= 2 ) == hcat ([sqrt (0.25 ), sqrt (0.25 )])
948+ @test Compat. Statistics. cov ([1 2 ; 3 4 ]) == [2 2 ; 2 2 ]
949+ @test Compat. Statistics. cov ([1 2 ; 3 4 ], dims= 1 ) == [2 2 ; 2 2 ]
950+ @test Compat. Statistics. cov ([1 2 ; 3 4 ], dims= 2 ) == [0.5 0.5 ; 0.5 0.5 ]
951+ @test Compat. Statistics. cov ([1 2 ; 3 4 ], [4 ; 5 ]) == hcat ([1 ; 1 ])
952+ @test Compat. Statistics. cov ([1 2 ; 3 4 ], [4 ; 5 ], dims= 1 ) == hcat ([1 ; 1 ])
953+ @test Compat. Statistics. cov ([1 2 ; 3 4 ], [4 ; 5 ], dims= 2 ) == hcat ([0.5 ; 0.5 ])
954+ @test Compat. Statistics. cov ([1 2 ; 3 4 ], [4 ; 5 ], corrected= false ) == hcat ([0.5 ; 0.5 ])
955+ @test Compat. Statistics. cov ([1 2 ; 3 4 ], [4 ; 5 ], corrected= false , dims= 1 ) == hcat ([0.5 ; 0.5 ])
956+ @test Compat. Statistics. cov ([1 2 ; 3 4 ], [4 ; 5 ], corrected= false , dims= 2 ) == hcat ([0.25 ; 0.25 ])
957+ @test Compat. Statistics. cor ([1 2 ; 3 4 ]) ≈ [1 1 ; 1 1 ]
958+ @test Compat. Statistics. cor ([1 2 ; 3 4 ], dims= 1 ) ≈ [1 1 ; 1 1 ]
959+ @test Compat. Statistics. cor ([1 2 ; 3 4 ], dims= 2 ) ≈ [1 1 ; 1 1 ]
960+ @test Compat. Statistics. cor ([1 2 ; 3 4 ], [4 ; 5 ]) ≈ [1 ; 1 ]
961+ @test Compat. Statistics. cor ([1 2 ; 3 4 ], [4 ; 5 ], dims= 1 ) ≈ [1 ; 1 ]
962+ @test Compat. Statistics. cor ([1 2 ; 3 4 ], [4 ; 5 ], dims= 2 ) ≈ [1 ; 1 ]
963+ end
964+ @test Compat. Statistics. median ([1 2 ; 3 4 ]) == 2.5
965+ @test Compat. Statistics. median ([1 2 ; 3 4 ], dims= 1 ) == [2 3 ]
966+ @test Compat. Statistics. median ([1 2 ; 3 4 ], dims= 2 ) == hcat ([1.5 ; 3.5 ])
967+ @test Compat. mapreduce (string, * , [1 2 ; 3 4 ]) == " 1324"
968+ Issue26488 && @test Compat. mapreduce (string, * , [1 2 ; 3 4 ], dims= 1 ) == [" 13" " 24" ]
969+ Issue26488 && @test Compat. mapreduce (string, * , [1 2 ; 3 4 ], dims= 2 ) == hcat ([" 12" , " 34" ])
970+ @test Compat. mapreduce (string, * , [1 2 ; 3 4 ], init= " z" ) == " z1324"
971+ @test Compat. mapreduce (string, * , (1 , 2 , 3 , 4 ), init= " z" ) == " z1234"
972+ @test Compat. mapreduce (string, * , [1 2 ; 3 4 ], dims= 1 , init= " z" ) == [" z13" " z24" ]
973+ @test Compat. mapreduce (string, * , [1 2 ; 3 4 ], dims= 2 , init= " z" ) == hcat ([" z12" , " z34" ])
974+ @test Compat. reduce (* , [1 2 ; 3 4 ]) == 24
975+ @test Compat. reduce (* , [1 2 ; 3 4 ], dims= 1 ) == [3 8 ]
976+ @test Compat. reduce (* , [1 2 ; 3 4 ], dims= 2 ) == hcat ([2 , 12 ])
977+ @test Compat. reduce (* , [1 2 ; 3 4 ], init= 10 ) == 240
978+ @test Compat. reduce (* , (1 , 2 , 3 , 4 ), init= 10 ) == 240
979+ @test Compat. reduce (* , [1 2 ; 3 4 ], dims= 1 , init= 10 ) == [30 80 ]
980+ @test Compat. reduce (* , [1 2 ; 3 4 ], dims= 2 , init= 10 ) == hcat ([20 , 120 ])
981+ @test Compat. sort ([1 , 2 , 3 , 4 ]) == [1 , 2 , 3 , 4 ]
982+ @test Compat. sort ([1 2 ; 3 4 ], dims= 1 ) == [1 2 ; 3 4 ]
983+ @test Compat. sort ([1 2 ; 3 4 ], dims= 2 ) == [1 2 ; 3 4 ]
984+ @test Compat. sort ([1 , 2 , 3 , 4 ], rev= true ) == [4 , 3 , 2 , 1 ]
985+ @test Compat. sort ([1 2 ; 3 4 ], rev= true , dims= 1 ) == [3 4 ; 1 2 ]
986+ @test Compat. sort ([1 2 ; 3 4 ], rev= true , dims= 2 ) == [2 1 ; 4 3 ]
987+ @test Compat. accumulate (* , [1 2 ; 3 4 ], dims= 1 ) == [1 2 ; 3 8 ]
988+ @test Compat. accumulate (* , [1 2 ; 3 4 ], dims= 2 ) == [1 2 ; 3 12 ]
989+ @test Compat. cumsum ([1 2 ; 3 4 ], dims= 1 ) == [1 2 ; 4 6 ]
990+ @test Compat. cumsum ([1 2 ; 3 4 ], dims= 2 ) == [1 3 ; 3 7 ]
991+ @test Compat. cumprod ([1 2 ; 3 4 ], dims= 1 ) == [1 2 ; 3 8 ]
992+ @test Compat. cumprod ([1 2 ; 3 4 ], dims= 2 ) == [1 2 ; 3 12 ]
993+ let b = zeros (2 ,2 )
994+ Compat. accumulate! (* , b, [1 2 ; 3 4 ], dims= 1 )
995+ @test b == [1 2 ; 3 8 ]
996+ Compat. accumulate! (* , b, [1 2 ; 3 4 ], dims= 2 )
997+ @test b == [1 2 ; 3 12 ]
998+ Compat. cumsum! (b, [1 2 ; 3 4 ], dims= 1 )
999+ @test b == [1 2 ; 4 6 ]
1000+ Compat. cumsum! (b, [1 2 ; 3 4 ], dims= 2 )
1001+ @test b == [1 3 ; 3 7 ]
1002+ Compat. cumprod! (b, [1 2 ; 3 4 ], dims= 1 )
1003+ @test b == [1 2 ; 3 8 ]
1004+ Compat. cumprod! (b, [1 2 ; 3 4 ], dims= 2 )
1005+ @test b == [1 2 ; 3 12 ]
1006+ end
1007+ @test Compat. reverse ([1 , 2 , 3 , 4 ]) == [4 , 3 , 2 , 1 ]
1008+ @test Compat. reverse ([1 2 ; 3 4 ], dims= 1 ) == [3 4 ; 1 2 ]
1009+ @test Compat. reverse ([1 2 ; 3 4 ], dims= 2 ) == [2 1 ; 4 3 ]
1010+
1011+ # 0.7.0-DEV.4738
1012+ if VERSION < v " 0.7.0-beta2.143"
1013+ @test squeeze ([1 2 ], dims= 1 ) == [1 , 2 ]
1014+ @test_throws ArgumentError squeeze ([1 2 ], dims= 2 )
1015+ @test_throws ArgumentError squeeze (hcat ([1 , 2 ]), dims= 1 )
1016+ @test squeeze (hcat ([1 , 2 ]), dims= 2 ) == [1 , 2 ]
1017+ @test_throws Exception squeeze ([1 ,2 ])
1018+ end
1019+
1020+ # 0.7.0-DEV.5165
1021+ @test Compat. cat ([1 , 2 ], [3 , 4 , 5 ], dims = 1 ) == [1 , 2 , 3 , 4 , 5 ]
1022+ @test Compat. cat ([1 , 2 ], [3 , 4 ], dims = 2 ) == [1 3 ; 2 4 ]
1023+ if VERSION < v " 0.7.0-DEV.5165"
1024+ @test_throws UndefKeywordError Compat. cat ([1 , 2 ], [3 , 4 ])
1025+ end
0 commit comments