|
479 | 479 | A = zeros(3, 4, 5); |
480 | 480 | A[:] = 1:60 |
481 | 481 | Ap = @view(PermutedDimsArray(A,(3,1,2))[:,1:2,1])'; |
482 | | - S = @SArray zeros(2,3,4); Sp = @view(PermutedDimsArray(S,(3,1,2))[2:3,1:2,:]); |
483 | | - M = @MArray zeros(2,3,4); Mp = @view(PermutedDimsArray(M,(3,1,2))[:,2,:])'; |
| 482 | + S = @SArray zeros(2,3,4) |
| 483 | + A_trailingdim = zeros(2,3,4,1) |
| 484 | + Sp = @view(PermutedDimsArray(S,(3,1,2))[2:3,1:2,:]); |
| 485 | + M = @MArray zeros(2,3,4) |
| 486 | + Mp = @view(PermutedDimsArray(M,(3,1,2))[:,2,:])'; |
484 | 487 | Sp2 = @view(PermutedDimsArray(S,(3,2,1))[2:3,:,:]); |
485 | 488 | Mp2 = @view(PermutedDimsArray(M,(3,1,2))[2:3,:,2])'; |
486 | 489 | D = @view(A[:,2:2:4,:]); |
|
490 | 493 | A2 = zeros(4, 3, 5) |
491 | 494 | A2r = reinterpret(ComplexF64, A2) |
492 | 495 |
|
| 496 | + irev = Iterators.reverse(S) |
| 497 | + igen = Iterators.map(identity, S) |
| 498 | + iacc = Iterators.accumulate(+, S) |
| 499 | + iprod = Iterators.product(axes(S)...) |
| 500 | + iflat = Iterators.flatten(iprod) |
| 501 | + ienum = enumerate(S) |
| 502 | + ipairs = pairs(S) |
| 503 | + izip = zip(S,S) |
| 504 | + |
| 505 | + |
493 | 506 | sv5 = @SVector(zeros(5)); v5 = Vector{Float64}(undef, 5); |
494 | 507 | @test @inferred(ArrayInterface.size(sv5)) === (StaticInt(5),) |
495 | 508 | @test @inferred(ArrayInterface.size(v5)) === (5,) |
|
503 | 516 | @test @inferred(ArrayInterface.size(A2)) === (4,3,5) |
504 | 517 | @test @inferred(ArrayInterface.size(A2r)) === (2,3,5) |
505 | 518 |
|
| 519 | + @test @inferred(ArrayInterface.size(irev)) === (StaticInt(2), StaticInt(3), StaticInt(4)) |
| 520 | + @test @inferred(ArrayInterface.size(iprod)) === (StaticInt(2), StaticInt(3), StaticInt(4)) |
| 521 | + @test @inferred(ArrayInterface.size(iflat)) === (static(72),) |
| 522 | + @test @inferred(ArrayInterface.size(igen)) === (StaticInt(2), StaticInt(3), StaticInt(4)) |
| 523 | + @test @inferred(ArrayInterface.size(iacc)) === (StaticInt(2), StaticInt(3), StaticInt(4)) |
| 524 | + @test @inferred(ArrayInterface.size(ienum)) === (StaticInt(2), StaticInt(3), StaticInt(4)) |
| 525 | + @test @inferred(ArrayInterface.size(ipairs)) === (StaticInt(2), StaticInt(3), StaticInt(4)) |
| 526 | + @test @inferred(ArrayInterface.size(izip)) === (StaticInt(2), StaticInt(3), StaticInt(4)) |
| 527 | + @test @inferred(ArrayInterface.size(zip(S, A_trailingdim))) === (StaticInt(2), StaticInt(3), StaticInt(4), static(1)) |
| 528 | + @test @inferred(ArrayInterface.size(zip(A_trailingdim, S))) === (StaticInt(2), StaticInt(3), StaticInt(4), static(1)) |
506 | 529 | @test @inferred(ArrayInterface.size(S)) === (StaticInt(2), StaticInt(3), StaticInt(4)) |
507 | 530 | @test @inferred(ArrayInterface.size(Sp)) === (2, 2, StaticInt(3)) |
508 | 531 | @test @inferred(ArrayInterface.size(Sp2)) === (2, StaticInt(3), StaticInt(2)) |
|
536 | 559 | @test @inferred(ArrayInterface.known_size(A2)) === (missing, missing, missing) |
537 | 560 | @test @inferred(ArrayInterface.known_size(A2r)) === (missing, missing, missing) |
538 | 561 |
|
| 562 | + @test @inferred(ArrayInterface.known_size(irev)) === (2, 3, 4) |
| 563 | + @test @inferred(ArrayInterface.known_size(igen)) === (2, 3, 4) |
| 564 | + @test @inferred(ArrayInterface.known_size(iprod)) === (2, 3, 4) |
| 565 | + @test @inferred(ArrayInterface.known_size(iflat)) === (72,) |
| 566 | + @test @inferred(ArrayInterface.known_size(iacc)) === (2, 3, 4) |
| 567 | + @test @inferred(ArrayInterface.known_size(ienum)) === (2, 3, 4) |
| 568 | + @test @inferred(ArrayInterface.known_size(izip)) === (2, 3, 4) |
| 569 | + @test @inferred(ArrayInterface.known_size(ipairs)) === (2, 3, 4) |
| 570 | + @test @inferred(ArrayInterface.known_size(zip(S, A_trailingdim))) === (2, 3, 4, 1) |
| 571 | + @test @inferred(ArrayInterface.known_size(zip(A_trailingdim, S))) === (2, 3, 4, 1) |
| 572 | + @test @inferred(ArrayInterface.known_length(Iterators.flatten(((x,y) for x in 0:1 for y in 'a':'c')))) === missing |
| 573 | + |
539 | 574 | @test @inferred(ArrayInterface.known_size(S)) === (2, 3, 4) |
540 | 575 | @test @inferred(ArrayInterface.known_size(Wrapper(S))) === (2, 3, 4) |
541 | 576 | @test @inferred(ArrayInterface.known_size(Sp)) === (missing, missing, 3) |
|
544 | 579 | @test @inferred(ArrayInterface.known_size(Sp2, StaticInt(1))) === missing |
545 | 580 | @test @inferred(ArrayInterface.known_size(Sp2, StaticInt(2))) === 3 |
546 | 581 | @test @inferred(ArrayInterface.known_size(Sp2, StaticInt(3))) === 2 |
547 | | - |
548 | 582 | @test @inferred(ArrayInterface.known_size(M)) === (2, 3, 4) |
549 | 583 | @test @inferred(ArrayInterface.known_size(Mp)) === (3, 4) |
550 | 584 | @test @inferred(ArrayInterface.known_size(Mp2)) === (2, missing) |
|
0 commit comments