File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed
Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 11name = " FillArrays"
22uuid = " 1a297f60-69ca-5386-bcde-b61e274b549b"
3- version = " 0.10.1 "
3+ version = " 0.10.2 "
44
55[deps ]
66LinearAlgebra = " 37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Original file line number Diff line number Diff line change 489489sum (x:: AbstractFill ) = getindex_value (x)* length (x)
490490sum (x:: Zeros ) = getindex_value (x)
491491
492+ # define `sum(::Callable, ::AbstractFill)` to avoid method ambiguity errors on Julia 1.0
493+ sum (f, x:: AbstractFill ) = _sum (f, x)
494+ sum (f:: Base.Callable , x:: AbstractFill ) = _sum (f, x)
495+ _sum (f, x:: AbstractFill ) = length (x) * f (getindex_value (x))
496+
492497cumsum (x:: AbstractFill{<:Any,1} ) = range (getindex_value (x); step= getindex_value (x),
493498 length= length (x))
494499
Original file line number Diff line number Diff line change @@ -508,18 +508,23 @@ end
508508
509509@testset " Cumsum and diff" begin
510510 @test sum (Fill (3 ,10 )) ≡ 30
511+ @test sum (x -> x + 1 , Fill (3 ,10 )) ≡ 40
511512 @test cumsum (Fill (3 ,10 )) ≡ 3 : 3 : 30
512513
513514 @test sum (Ones (10 )) ≡ 10.0
515+ @test sum (x -> x + 1 , Ones (10 )) ≡ 20.0
514516 @test cumsum (Ones (10 )) ≡ 1.0 : 10.0
515517
516518 @test sum (Ones {Int} (10 )) ≡ 10
519+ @test sum (x -> x + 1 , Ones {Int} (10 )) ≡ 20
517520 @test cumsum (Ones {Int} (10 )) ≡ Base. OneTo (10 )
518521
519522 @test sum (Zeros (10 )) ≡ 0.0
523+ @test sum (x -> x + 1 , Zeros (10 )) ≡ 10.0
520524 @test cumsum (Zeros (10 )) ≡ Zeros (10 )
521525
522526 @test sum (Zeros {Int} (10 )) ≡ 0
527+ @test sum (x -> x + 1 , Zeros {Int} (10 )) ≡ 10
523528 @test cumsum (Zeros {Int} (10 )) ≡ Zeros {Int} (10 )
524529
525530 @test cumsum (Zeros {Bool} (10 )) ≡ Zeros {Bool} (10 )
You can’t perform that action at this time.
0 commit comments