File tree 3 files changed +11
-1
lines changed
3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 1
1
name = " FillArrays"
2
2
uuid = " 1a297f60-69ca-5386-bcde-b61e274b549b"
3
- version = " 0.10.1 "
3
+ version = " 0.10.2 "
4
4
5
5
[deps ]
6
6
LinearAlgebra = " 37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Original file line number Diff line number Diff line change 489
489
sum (x:: AbstractFill ) = getindex_value (x)* length (x)
490
490
sum (x:: Zeros ) = getindex_value (x)
491
491
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
+
492
497
cumsum (x:: AbstractFill{<:Any,1} ) = range (getindex_value (x); step= getindex_value (x),
493
498
length= length (x))
494
499
Original file line number Diff line number Diff line change @@ -508,18 +508,23 @@ end
508
508
509
509
@testset " Cumsum and diff" begin
510
510
@test sum (Fill (3 ,10 )) ≡ 30
511
+ @test sum (x -> x + 1 , Fill (3 ,10 )) ≡ 40
511
512
@test cumsum (Fill (3 ,10 )) ≡ 3 : 3 : 30
512
513
513
514
@test sum (Ones (10 )) ≡ 10.0
515
+ @test sum (x -> x + 1 , Ones (10 )) ≡ 20.0
514
516
@test cumsum (Ones (10 )) ≡ 1.0 : 10.0
515
517
516
518
@test sum (Ones {Int} (10 )) ≡ 10
519
+ @test sum (x -> x + 1 , Ones {Int} (10 )) ≡ 20
517
520
@test cumsum (Ones {Int} (10 )) ≡ Base. OneTo (10 )
518
521
519
522
@test sum (Zeros (10 )) ≡ 0.0
523
+ @test sum (x -> x + 1 , Zeros (10 )) ≡ 10.0
520
524
@test cumsum (Zeros (10 )) ≡ Zeros (10 )
521
525
522
526
@test sum (Zeros {Int} (10 )) ≡ 0
527
+ @test sum (x -> x + 1 , Zeros {Int} (10 )) ≡ 10
523
528
@test cumsum (Zeros {Int} (10 )) ≡ Zeros {Int} (10 )
524
529
525
530
@test cumsum (Zeros {Bool} (10 )) ≡ Zeros {Bool} (10 )
You can’t perform that action at this time.
0 commit comments