1+ @testitem " xmap" begin
2+ using YAXArrays
3+ using DimensionalData
4+ @testset " Loop Axis permutation" begin
5+ x,y,z = X(1 : 4 ), Y(1 : 5 ), Z(1 : 6 )
6+ a1 = YAXArray((x,y,z), rand(4 ,5 ,6 ))
7+ a2 = YAXArray((x,z,y), rand(4 ,6 ,5 ))
8+ a3 = YAXArray((x,y), rand(4 ,5 ))
9+ r = xmap(a1 ⊘ X, a2 ⊘ X, output = XOutput(dims(a1, X))) do xout, x1, x2
10+ xout .= x1 .+ x2
11+ end
12+ @test r. data == a1. data .+ permutedims(a2. data,(1 ,3 ,2 ))
13+ r = xmap(a2 ⊘ X, a3 ⊘ X, output= XOutput(dims(a1, X))) do xout, x1, x2
14+ xout .= x1 .+ x2
15+ end
16+ @test r. data == a2. data .+ reshape(a3. data,(4 ,1 ,5 ))
17+ # r = xmap(a2 ⊘ X, a3 ⊘ X, output=XOutput(dims(a1, X)),nthreads = [1]) do xout, x1, x2
18+ # xout .= x1 .+ x2
19+ # end
20+ @test r. data == a2. data .+ reshape(a3. data,(4 ,1 ,5 ))
21+ end
22+
23+
24+ #=
25+ These should be reenabled once we decided what keyword arguments xmap gets.
26+ @testset "max cache inputs" begin
27+
28+ x,y,z = X(1:4), Y(1:5), Z(1:6)
29+ a1 = YAXArray((x,y,z), rand(4,5,6))
30+ a2 = YAXArray((x,z,y), rand(4,6,5))
31+ a3 = YAXArray((x,y), rand(4,5))
32+ indims = InDims("x")
33+ outdims = OutDims("x")
34+
35+ function simple_fun(xout, x1,x2)
36+ xout .= x1 .+ x2
37+ end
38+
39+ # Float64
40+ r = xmap(simple_fun, a1 ⊘ :X, a2 ⊘ :X, output=XOutput(:X), max_cache = 6.0e8)
41+ @test r.data == a1.data .+ permutedims(a2.data,(1,3,2))
42+
43+ # MB
44+ r = mapCube(simple_fun, (a1, a2), indims=(indims, indims), outdims=outdims, max_cache = "0.5MB")
45+ @test r.data == a1.data .+ permutedims(a2.data,(1,3,2))
46+
47+ r = mapCube(simple_fun, (a1, a2), indims=(indims, indims), outdims=outdims, max_cache = "3MB")
48+ @test r.data == a1.data .+ permutedims(a2.data,(1,3,2))
49+
50+ r = mapCube(simple_fun, (a1, a2), indims=(indims, indims), outdims=outdims, max_cache = "10MB")
51+ @test r.data == a1.data .+ permutedims(a2.data,(1,3,2))
52+
53+ # GB
54+ r = mapCube(simple_fun, (a1, a2), indims=(indims, indims), outdims=outdims, max_cache = "0.1GB")
55+ @test r.data == a1.data .+ permutedims(a2.data,(1,3,2))
56+ end
57+
58+ @testset "Error shown in parallel" begin
59+ import Zarr
60+ x,y,z = X(1:4), Y(1:5), Z(1:6)
61+ a1 = YAXArray((x,y,z), rand(4,5,6))
62+ indims = InDims("x")
63+ outdims = OutDims("x")
64+ @test_throws Exception mapCube((xout, xin) -> xout .= foo(xin), a1; indims, outdims, ispar=false)
65+ @test_throws CapturedException mapCube((xout, xin) -> xout .= foo(xin), a1; indims, outdims, ispar=true)
66+ end
67+ =#
68+ end
0 commit comments