@@ -9,7 +9,7 @@ addprocs(2)
99 using ParallelUtilities
1010 import ParallelUtilities: BinaryTreeNode, RemoteChannelContainer, BranchChannel,
1111 Sorted, Unsorted, Ordering, pval, value, reducedvalue, reduceTreeNode,
12- BinaryTree, parentnoderank, nchildren, infer_returntypes
12+ BinaryTree, parentnoderank, nchildren, infer_returntypes, maybepvalput!
1313end
1414
1515@testset " ProductSplit" begin
772772 @testset " pval" begin
773773 p = pval (myid (),3 )
774774 q = pval (3 )
775- @test p == q
775+ r = pval {Int} (3.0 )
776+ s = pval {Int} (3 )
777+ @test p == q == r == s
776778 @test value (p) == 3
777779 @test value (3 ) == 3
778780 @test value (p) == value (q)
@@ -785,36 +787,77 @@ end
785787 @testset " infer_returntypes" begin
786788 iterable = 1 : 10
787789 iterators = (iterable,)
790+ iteratorsPS = evenlyscatterproduct (iterators,1 ,1 )
788791 fmap = x -> 1
789792 fred = sum
790793 @test infer_returntypes (fmap,fred,iterators) == (Int,Int)
791- @test infer_returntypes (fmap,fred,iterable) == (Int,Int)
792- @test infer_returntypes (fmap,fred,Iterators. product (iterable)) == (Int,Int)
794+ @test infer_returntypes (fmap,fred,iteratorsPS) == (Int,Int)
793795
794796 fmap = x-> ones (Int,1 )
795797 fred = x-> hcat (x... )
796798 @test infer_returntypes (fmap,fred,iterators) == (Vector{Int},Matrix{Int})
797- @test infer_returntypes (fmap,fred,iterable) == (Vector{Int},Matrix{Int})
798- @test infer_returntypes (fmap,fred,Iterators. product (iterable)) == (Vector{Int},Matrix{Int})
799+ @test infer_returntypes (fmap,fred,iteratorsPS) == (Vector{Int},Matrix{Int})
800+
801+ fmap (x:: ProductSplit ,y) = sum (i[1 ] for i in x) + y
802+ fred = sum
803+ @test infer_returntypes (fmap,fred,iteratorsPS,1 ) == (Int,Int)
799804 end
800805
801806 @testset " mapTreeNode" begin
802807
803808 @testset " maybepvalput!" begin
804809 pipe = BranchChannel {Int,Int} (0 )
805- ParallelUtilities . maybepvalput! (pipe,0 )
810+ maybepvalput! (pipe,0 )
806811 @test isready (pipe. selfchannels. out)
807812 @test take! (pipe. selfchannels. out) == 0
808813
809814 pipe = BranchChannel {pval,pval} (0 )
810- ParallelUtilities . maybepvalput! (pipe,0 )
815+ maybepvalput! (pipe,0 )
811816 @test isready (pipe. selfchannels. out)
812817 @test take! (pipe. selfchannels. out) == pval (0 )
813818
814819 pipe = BranchChannel {pval{Int},pval{Int}} (0 )
815- ParallelUtilities . maybepvalput! (pipe,0 )
820+ maybepvalput! (pipe,0 )
816821 @test isready (pipe. selfchannels. out)
817822 @test take! (pipe. selfchannels. out) == pval (0 )
823+
824+ T = Vector{ComplexF64}
825+ pipe = BranchChannel {pval{T},pval{T}} (1 )
826+
827+ val = ones (1 ).* im
828+ maybepvalput! (pipe,val)
829+ @test isready (pipe. selfchannels. out)
830+ @test take! (pipe. selfchannels. out) == pval (ComplexF64[im])
831+
832+ val = ones (1 )
833+ maybepvalput! (pipe,val)
834+ @test isready (pipe. selfchannels. out)
835+ @test take! (pipe. selfchannels. out) == pval (ComplexF64[1 ])
836+
837+ T = Vector{Float64}
838+ pipe = BranchChannel {pval{T},pval{T}} (1 )
839+
840+ val = ones (1 )
841+ maybepvalput! (pipe,val)
842+ @test isready (pipe. selfchannels. out)
843+ @test take! (pipe. selfchannels. out) == pval (Float64[1 ])
844+
845+ val = ones (Int,1 )
846+ maybepvalput! (pipe,val)
847+ @test isready (pipe. selfchannels. out)
848+ @test take! (pipe. selfchannels. out) == pval (Float64[1 ])
849+
850+ pipe = BranchChannel {pval,pval} (1 )
851+
852+ val = ones (1 )
853+ maybepvalput! (pipe,val)
854+ @test isready (pipe. selfchannels. out)
855+ @test take! (pipe. selfchannels. out) == pval (Float64[1 ])
856+
857+ val = ones (Int,1 )
858+ maybepvalput! (pipe,val)
859+ @test isready (pipe. selfchannels. out)
860+ @test take! (pipe. selfchannels. out) == pval (Int[1 ])
818861 end
819862
820863 function test_on_pipe (fn,iterator,pipe,result_expected)
@@ -1082,14 +1125,19 @@ end
10821125 res_exp = sum (1 : nworkers ())
10831126 @test pmapsum (x-> workerrank (),Int,1 : nworkers ()) == res_exp
10841127 @test pmapsum (x-> workerrank (),1 : nworkers ()) == res_exp
1128+ @test pmapsum (x-> workerrank (),1 : nworkers (),infer_types = false ) == res_exp
10851129 @test pmapsum (x-> workerrank (),Int,(1 : nworkers (),)) == res_exp
10861130 @test pmapsum (x-> workerrank (),(1 : nworkers (),)) == res_exp
1131+ @test pmapsum (x-> workerrank (),(1 : nworkers (),),infer_types = false ) == res_exp
10871132 @test pmapsum (x-> workerrank (),Int,Iterators. product (1 : nworkers ())) == res_exp
10881133 @test pmapsum (x-> workerrank (),Iterators. product (1 : nworkers ())) == res_exp
1134+ @test pmapsum (x-> workerrank (),Iterators. product (1 : nworkers ()),infer_types = false ) == res_exp
10891135 @test pmapsum (x-> workerrank (),Int,(1 : nworkers (),1 : 1 )) == res_exp
10901136 @test pmapsum (x-> workerrank (),(1 : nworkers (),1 : 1 )) == res_exp
1137+ @test pmapsum (x-> workerrank (),(1 : nworkers (),1 : 1 ),infer_types = false ) == res_exp
10911138 @test pmapsum (x-> workerrank (),Int,Iterators. product (1 : nworkers (),1 : 1 )) == res_exp
10921139 @test pmapsum (x-> workerrank (),Iterators. product (1 : nworkers (),1 : 1 )) == res_exp
1140+ @test pmapsum (x-> workerrank (),Iterators. product (1 : nworkers (),1 : 1 ),infer_types = false ) == res_exp
10931141 @test pmapsum (x-> myid (),1 : nworkers ()) == sum (workers ())
10941142 end
10951143
@@ -1123,7 +1171,7 @@ end
11231171 end
11241172
11251173 @testset " errors" begin
1126- @test_throws exceptiontype pmapsum (x-> throws ( BoundsError () ),1 : 10 )
1174+ @test_throws exceptiontype pmapsum (x-> error ( " map " ),1 : 10 )
11271175 end
11281176 end
11291177
@@ -1159,7 +1207,7 @@ end
11591207 end
11601208
11611209 @testset " errors" begin
1162- @test_throws exceptiontype pmapsum_elementwise (x-> throws ( BoundsError () ),1 : 10 )
1210+ @test_throws exceptiontype pmapsum_elementwise (x-> error ( " hi " ),1 : 10 )
11631211 end
11641212 end
11651213
@@ -1175,14 +1223,19 @@ end
11751223 res_exp = sum (workers ())
11761224 @test pmapreduce_commutative (x-> myid (),Int,sum,Int,1 : nworkers ()) == res_exp
11771225 @test pmapreduce_commutative (x-> myid (),sum,1 : nworkers ()) == res_exp
1226+ @test pmapreduce_commutative (x-> myid (),sum,1 : nworkers (),infer_types = false ) == res_exp
11781227 @test pmapreduce_commutative (x-> myid (),Int,sum,Int,(1 : nworkers (),)) == res_exp
11791228 @test pmapreduce_commutative (x-> myid (),sum,(1 : nworkers (),)) == res_exp
1229+ @test pmapreduce_commutative (x-> myid (),sum,(1 : nworkers (),),infer_types = false ) == res_exp
11801230 @test pmapreduce_commutative (x-> myid (),Int,sum,Int,Iterators. product (1 : nworkers ())) == res_exp
11811231 @test pmapreduce_commutative (x-> myid (),sum,Iterators. product (1 : nworkers ())) == res_exp
1232+ @test pmapreduce_commutative (x-> myid (),sum,Iterators. product (1 : nworkers ()),infer_types = false ) == res_exp
11821233 @test pmapreduce_commutative (x-> myid (),Int,sum,Int,(1 : nworkers (),1 : 1 )) == res_exp
11831234 @test pmapreduce_commutative (x-> myid (),sum,(1 : nworkers (),1 : 1 )) == res_exp
1235+ @test pmapreduce_commutative (x-> myid (),sum,(1 : nworkers (),1 : 1 ),infer_types = false ) == res_exp
11841236 @test pmapreduce_commutative (x-> myid (),Int,sum,Int,Iterators. product (1 : nworkers (),1 : 1 )) == res_exp
11851237 @test pmapreduce_commutative (x-> myid (),sum,Iterators. product (1 : nworkers (),1 : 1 )) == res_exp
1238+ @test pmapreduce_commutative (x-> myid (),sum,Iterators. product (1 : nworkers (),1 : 1 ),infer_types = false ) == res_exp
11861239 @test pmapreduce_commutative (x-> myid (),sum,1 : nworkers ()) == pmapsum (x-> myid (),1 : nworkers ())
11871240 end
11881241 @testset " prod" begin
@@ -1203,12 +1256,11 @@ end
12031256
12041257 @testset " errors" begin
12051258 @test_throws exceptiontype pmapreduce_commutative (
1206- x-> throws ( BoundsError () ),sum,1 : 10 )
1259+ x-> error ( " map " ),sum,1 : 10 )
12071260 @test_throws exceptiontype pmapreduce_commutative (
1208- identity,x-> throws ( BoundsError () ),1 : 10 )
1261+ identity,x-> error ( " reduce " ),1 : 10 )
12091262 @test_throws exceptiontype pmapreduce_commutative (
1210- x-> throw (ErrorException (" eh" )),
1211- x-> throws (BoundsError ()),1 : 10 )
1263+ x-> error (" map" ),x-> error (" reduce" ),1 : 10 )
12121264 end
12131265 @testset " type coercion" begin
12141266 @test_throws exceptiontype pmapreduce_commutative (x-> [1.1 ],Vector{Int},
@@ -1250,12 +1302,12 @@ end
12501302
12511303 @testset " errors" begin
12521304 @test_throws exceptiontype pmapreduce_commutative_elementwise (
1253- x-> throws ( BoundsError () ),sum,1 : 10 )
1305+ x-> error ( " map " ),sum,1 : 10 )
12541306 @test_throws exceptiontype pmapreduce_commutative_elementwise (
1255- identity,x-> throws ( BoundsError () ),1 : 10 )
1307+ identity,x-> error ( " reduce " ),1 : 10 )
12561308 @test_throws exceptiontype pmapreduce_commutative_elementwise (
1257- x-> throw ( ErrorException ( " eh " ) ),
1258- x-> throws ( BoundsError () ),1 : 10 )
1309+ x-> error ( " map " ),
1310+ x-> error ( " reduce " ),1 : 10 )
12591311 end
12601312 end
12611313 end
@@ -1266,14 +1318,18 @@ end
12661318 res_exp = sum (workers ())
12671319 @test pmapreduce (x-> myid (),Int,sum,Int,1 : nworkers ()) == res_exp
12681320 @test pmapreduce (x-> myid (),sum,1 : nworkers ()) == res_exp
1321+ @test pmapreduce (x-> myid (),sum,1 : nworkers (),infer_types = false ) == res_exp
12691322 @test pmapreduce (x-> myid (),Int,sum,Int,(1 : nworkers (),)) == res_exp
12701323 @test pmapreduce (x-> myid (),sum,(1 : nworkers (),)) == res_exp
1324+ @test pmapreduce (x-> myid (),sum,(1 : nworkers (),),infer_types = false ) == res_exp
12711325 @test pmapreduce (x-> myid (),Int,sum,Int,Iterators. product (1 : nworkers ())) == res_exp
12721326 @test pmapreduce (x-> myid (),sum,Iterators. product (1 : nworkers ())) == res_exp
12731327 @test pmapreduce (x-> myid (),Int,sum,Int,(1 : nworkers (),1 : 1 )) == res_exp
12741328 @test pmapreduce (x-> myid (),sum,(1 : nworkers (),1 : 1 )) == res_exp
1329+ @test pmapreduce (x-> myid (),sum,(1 : nworkers (),1 : 1 ),infer_types = false ) == res_exp
12751330 @test pmapreduce (x-> myid (),Int,sum,Int,Iterators. product (1 : nworkers (),1 : 1 )) == res_exp
12761331 @test pmapreduce (x-> myid (),sum,Iterators. product (1 : nworkers (),1 : 1 )) == res_exp
1332+ @test pmapreduce (x-> myid (),sum,Iterators. product (1 : nworkers (),1 : 1 ),infer_types = false ) == res_exp
12771333 @test pmapreduce (x-> myid (),Int,sum,Int,1 : nworkers ()) == pmapsum (x-> myid (),Int,1 : nworkers ())
12781334 @test pmapreduce (x-> myid (),Int,sum,Int,1 : nworkers ()) == pmapsum (x-> myid (),1 : nworkers ())
12791335 @test pmapreduce (x-> myid (),sum,1 : nworkers ()) == pmapsum (x-> myid (),1 : nworkers ())
@@ -1285,6 +1341,7 @@ end
12851341 @test pmapreduce (x-> ones (2 ),Vector{Float64},
12861342 x-> vcat (x... ),Vector{Float64},1 : nworkers ()) == res_vcat
12871343 @test pmapreduce (x-> ones (2 ),x-> vcat (x... ),1 : nworkers ()) == res_vcat
1344+ @test pmapreduce (x-> ones (2 ),x-> vcat (x... ),1 : nworkers (),infer_types = false ) == res_vcat
12881345 @test pmapreduce (x-> ones (2 ),Vector{Float64},
12891346 x-> hcat (x... ),Matrix{Float64},1 : nworkers ()) == res_hcat
12901347 @test pmapreduce (x-> ones (2 ),x-> hcat (x... ),1 : nworkers ()) == res_hcat
@@ -1308,10 +1365,9 @@ end
13081365 end
13091366
13101367 @testset " errors" begin
1311- @test_throws exceptiontype pmapreduce (x-> throws (BoundsError ()),sum,1 : 10 )
1312- @test_throws exceptiontype pmapreduce (identity,x-> throws (BoundsError ()),1 : 10 )
1313- @test_throws exceptiontype pmapreduce (x-> throw (ErrorException (" eh" )),
1314- x-> throws (BoundsError ()),1 : 10 )
1368+ @test_throws exceptiontype pmapreduce (x-> error (" map" ),sum,1 : 10 )
1369+ @test_throws exceptiontype pmapreduce (identity,x-> error (" reduce" ),1 : 10 )
1370+ @test_throws exceptiontype pmapreduce (x-> error (" map" ),x-> error (" reduce" ),1 : 10 )
13151371 end
13161372
13171373 @testset " type coercion" begin
0 commit comments