@@ -655,30 +655,24 @@ end
655
655
656
656
check_leaks ()
657
657
658
- # The mapslices tests have been taken from Base.
659
- # Commented out tests that need to be enabled in due course when DArray support is more complete
660
658
@testset " test mapslices" begin
661
- a = drand ((5 ,5 ), workers (), [1 , min (nworkers (), 5 )])
662
- h = mapslices (v -> fit (Histogram,v,0 : 0.1 : 1 ). weights, a, 1 )
663
- # H = mapslices(v -> hist(v,0:0.1:1)[2], a, 2)
664
- # s = mapslices(sort, a, [1])
665
- # S = mapslices(sort, a, [2])
666
- for i = 1 : 5
667
- @test h[:,i] == fit (Histogram, a[:,i],0 : 0.1 : 1 ). weights
668
- # @test vec(H[i,:]) => hist(vec(a[i,:]),0:0.1:1)[2]
669
- # @test s[:,i] => sort(a[:,i])
670
- # @test vec(S[i,:]) => sort(vec(a[i,:]))
671
- end
659
+ A = randn (5 ,5 ,5 )
660
+ D = distribute (A, procs = workers (), dist = [1 , 1 , min (nworkers (), 5 )])
661
+ @test mapslices (svdvals, D, (1 ,2 )) ≈ mapslices (svdvals, A, (1 ,2 ))
662
+ @test mapslices (svdvals, D, (1 ,3 )) ≈ mapslices (svdvals, A, (1 ,3 ))
663
+ @test mapslices (svdvals, D, (2 ,3 )) ≈ mapslices (svdvals, A, (2 ,3 ))
664
+ @test mapslices (sort, D, (1 ,)) ≈ mapslices (sort, A, (1 ,))
665
+ @test mapslices (sort, D, (2 ,)) ≈ mapslices (sort, A, (2 ,))
666
+ @test mapslices (sort, D, (3 ,)) ≈ mapslices (sort, A, (3 ,))
672
667
673
668
# issue #3613
674
- b = mapslices (sum, dones (Float64, (2 ,3 ,4 ), workers (), [1 ,1 ,min (nworkers (),4 )]), [1 ,2 ])
675
- @test size (b ) == (1 ,1 ,4 )
676
- @test all (b .== 6 )
669
+ B = mapslices (sum, dones (Float64, (2 ,3 ,4 ), workers (), [1 ,1 ,min (nworkers (),4 )]), [1 ,2 ])
670
+ @test size (B ) == (1 ,1 ,4 )
671
+ @test all (B .== 6 )
677
672
678
673
# issue #5141
679
- # # Update Removed the version that removes the dimensions when dims==1:ndims(A)
680
- c1 = mapslices (x-> maximum (- x), a, [])
681
- # @test c1 => -a
674
+ C1 = mapslices (x-> maximum (- x), D, [])
675
+ @test C1 == - D
682
676
683
677
# issue #5177
684
678
c = dones (Float64, (2 ,3 ,4 ,5 ), workers (), [1 ,1 ,1 ,min (nworkers (),5 )])
@@ -695,7 +689,7 @@ check_leaks()
695
689
n3a = mapslices (x-> ones (1 ,6 ), c, [2 ,3 ])
696
690
@test (size (n1a) == (1 ,6 ,4 ,5 ) && size (n2a) == (1 ,3 ,6 ,5 ) && size (n3a) == (2 ,1 ,6 ,5 ))
697
691
@test (size (n1) == (6 ,1 ,4 ,5 ) && size (n2) == (6 ,3 ,1 ,5 ) && size (n3) == (2 ,6 ,1 ,5 ))
698
- close (a )
692
+ close (D )
699
693
close (c)
700
694
darray_closeall () # close the temporaries created above
701
695
end
0 commit comments