@@ -492,22 +492,52 @@ end
492
492
@test slic == Float64[1 , 2 , 3 , 4 , 1 , 2 , 3 , 4 ]
493
493
end
494
494
495
+ @testset " Concat DiskArray with fill zero tiles" begin
496
+ a = zeros (Int, 3 , 4 )
497
+ b = ones (Int, 2 , 4 )
498
+ c = fill (2 , 3 , 5 )
499
+ d = fill (0 , 2 , 5 )
500
+ aconc = DiskArrays. ConcatDiskArray (reshape ([a, b, c, DiskArrays. MissingTile (0 )], 2 , 2 ))
501
+ abase = [a c; b d]
502
+ @test all (isequal .(aconc[:, :], abase))
503
+ @test all (isequal .(aconc[3 : 4 , 4 : 6 ], abase[3 : 4 , 4 : 6 ]))
504
+ ch = DiskArrays. eachchunk (aconc)
505
+ @test ch. chunks[1 ] == [1 : 3 , 4 : 5 ]
506
+ @test ch. chunks[2 ] == [1 : 4 , 5 : 9 ]
507
+ @test eltype (aconc) == Int
508
+
509
+ a = ones (100 , 50 )
510
+ b = [rem (i. I[3 ], 5 ) == 0 ? DiskArrays. MissingTile (0 ) : a for i in CartesianIndices ((1 , 1 , 100 ))]
511
+ b[1 ] = DiskArrays. MissingTile (0 )
512
+ a_conc = DiskArrays. ConcatDiskArray (b)
513
+ ch = eachchunk (a_conc)
514
+ @test ch. chunks[1 ] == [1 : 100 ]
515
+ @test ch. chunks[2 ] == [1 : 50 ]
516
+ @test ch. chunks[3 ] === DiskArrays. RegularChunks (1 , 0 , 100 )
517
+
518
+ @test all (isequal .(a_conc[2 , 2 , 1 : 5 ], [0 , 1.0 , 1.0 , 1.0 , 0 ]))
519
+ @test all (isequal .(a_conc[end , end , 95 : 100 ], [0 , 1.0 , 1.0 , 1.0 , 1.0 , 0 ]))
520
+
521
+ end
522
+
523
+
495
524
@testset " Concat DiskArray with missing tiles" begin
496
525
a = zeros (Int, 3 , 4 )
497
526
b = ones (Int, 2 , 4 )
498
527
c = fill (2 , 3 , 5 )
499
528
d = fill (missing , 2 , 5 )
500
- aconc = DiskArrays. ConcatDiskArray (reshape ([a, b, c, missing ], 2 , 2 ))
529
+ aconc = DiskArrays. ConcatDiskArray (reshape ([a, b, c, DiskArrays . MissingTile ( missing ) ], 2 , 2 ))
501
530
abase = [a c; b d]
502
531
@test all (isequal .(aconc[:, :], abase))
503
532
@test all (isequal .(aconc[3 : 4 , 4 : 6 ], abase[3 : 4 , 4 : 6 ]))
504
533
ch = DiskArrays. eachchunk (aconc)
505
534
@test ch. chunks[1 ] == [1 : 3 , 4 : 5 ]
506
535
@test ch. chunks[2 ] == [1 : 4 , 5 : 9 ]
536
+ @test eltype (aconc) == Union{Int, Missing}
507
537
508
538
a = ones (100 , 50 )
509
- b = [rem (i. I[3 ], 5 ) == 0 ? missing : a for i in CartesianIndices ((1 , 1 , 100 ))]
510
- b[1 ] = missing
539
+ b = [rem (i. I[3 ], 5 ) == 0 ? DiskArrays . MissingTile ( missing ) : a for i in CartesianIndices ((1 , 1 , 100 ))]
540
+ b[1 ] = DiskArrays . MissingTile ( missing )
511
541
a_conc = DiskArrays. ConcatDiskArray (b)
512
542
ch = eachchunk (a_conc)
513
543
@test ch. chunks[1 ] == [1 : 100 ]
518
548
@test all (isequal .(a_conc[end , end , 95 : 100 ], [missing , 1.0 , 1.0 , 1.0 , 1.0 , missing ]))
519
549
520
550
end
551
+
552
+ @testset " Concat DiskArray with fill zero vector tiles" begin
553
+ a = fill ([1 ,1 ], 3 , 4 )
554
+ b = fill ([1 ,2 ], 2 , 4 )
555
+ c = fill ([2 ,1 ], 3 , 5 )
556
+ d = fill ([2 ,2 ], 2 , 5 )
557
+ aconc = DiskArrays. ConcatDiskArray (reshape ([a, b, c, DiskArrays. MissingTile ([2 ,2 ])], 2 , 2 ))
558
+ abase = [a c; b d]
559
+ @test all (isequal .(aconc[:, :], abase))
560
+ @test all (isequal .(aconc[3 : 4 , 4 : 6 ], abase[3 : 4 , 4 : 6 ]))
561
+ ch = DiskArrays. eachchunk (aconc)
562
+ @test ch. chunks[1 ] == [1 : 3 , 4 : 5 ]
563
+ @test ch. chunks[2 ] == [1 : 4 , 5 : 9 ]
564
+ @test eltype (aconc) == Vector{Int}
565
+
566
+ a = fill ([1 ,1 ], 100 , 50 )
567
+ b = [rem (i. I[3 ], 5 ) == 0 ? DiskArrays. MissingTile ([0 ,0 ]) : a for i in CartesianIndices ((1 , 1 , 100 ))]
568
+ b[1 ] = DiskArrays. MissingTile ([0 ,0 ])
569
+ a_conc = DiskArrays. ConcatDiskArray (b)
570
+ ch = eachchunk (a_conc)
571
+ @test ch. chunks[1 ] == [1 : 100 ]
572
+ @test ch. chunks[2 ] == [1 : 50 ]
573
+ @test ch. chunks[3 ] === DiskArrays. RegularChunks (1 , 0 , 100 )
574
+
575
+ @test all (isequal .(a_conc[2 , 2 , 1 : 5 ], [[0 ,0 ], [1 ,1 ],[1 ,1 ] , [1 ,1 ], [0 ,0 ]]))
576
+ @test all (isequal .(a_conc[end , end , 95 : 100 ], [[0 ,0 ], [1 ,1 ], [1 ,1 ], [1 ,1 ],[1 ,1 ], [0 ,0 ]]))
577
+
578
+ end
579
+
521
580
end
522
581
523
582
@testset " Broadcast with length 1 and 0 final dim" begin
@@ -929,8 +988,10 @@ struct TestArray{T,N} <: AbstractArray{T,N} end
929
988
DiskArrays. @implement_array_methods TestArray
930
989
DiskArrays. @implement_permutedims TestArray
931
990
DiskArrays. @implement_subarray TestArray
932
- DiskArrays. @implement_diskarray TestArray
933
991
@test DiskArrays. isdisk (TestArray) == true
992
+ DiskArrays. @implement_diskarray TestArray2
993
+ @test DiskArrays. isdisk (TestArray2) == true
994
+
934
995
end
935
996
936
997
# issue #123
0 commit comments