|
489 | 489 | sum(reshape(PermutedDimsArray(reshape(Float32.(1:30), 5, 3, 2), (3, 1, 2)), (10, 3)); dims=1) |
490 | 490 | end |
491 | 491 |
|
492 | | -@testset "accumulate" begin |
493 | | - for n in (0, 1, 2, 3, 10, 10_000, 16384, 16384+1) # small, large, odd & even, pow2 and not |
494 | | - @test testf(x->accumulate(+, x), rand(Float32, n)) |
495 | | - @test testf(x->accumulate(+, x), rand(Float32, n, 2)) |
496 | | - @test testf(Base.Fix2((x,y)->accumulate(+, x; init=y), rand(Float32)), rand(Float32, n)) |
497 | | - end |
498 | | - |
499 | | - # multidimensional |
500 | | - for (sizes, dims) in ((2,) => 2, |
501 | | - (3,4,5) => 2, |
502 | | - (1, 70, 50, 20) => 3,) |
503 | | - @test testf(x->accumulate(+, x; dims=dims), rand(-10:10, sizes)) |
504 | | - @test testf(x->accumulate(+, x), rand(-10:10, sizes)) |
505 | | - end |
506 | | - |
507 | | - # using initializer |
508 | | - for (sizes, dims) in ((2,) => 2, |
509 | | - (3,4,5) => 2, |
510 | | - (1, 70, 50, 20) => 3) |
511 | | - @test testf(Base.Fix2((x,y)->accumulate(+, x; dims=dims, init=y), rand(-10:10)), rand(-10:10, sizes)) |
512 | | - @test testf(Base.Fix2((x,y)->accumulate(+, x; init=y), rand(-10:10)), rand(-10:10, sizes)) |
513 | | - end |
514 | | - |
515 | | - # in place |
516 | | - @test testf(x->(accumulate!(+, x, copy(x)); x), rand(Float32, 2)) |
517 | | - |
518 | | - # specialized |
519 | | - @test testf(cumsum, rand(Float32, 2)) |
520 | | - @test testf(cumprod, rand(Float32, 2)) |
521 | | -end |
522 | | - |
523 | 492 | @testset "findall" begin |
524 | 493 | # 1D |
525 | 494 | @test testf(x->findall(x), rand(Bool, 1000)) |
|
0 commit comments