Skip to content

Commit 5ca17a1

Browse files
committed
Fix addition of complex-valued Fill and ranges
1 parent a8bffd3 commit 5ca17a1

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "FillArrays"
22
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
3-
version = "0.12.6"
3+
version = "0.12.7"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/FillArrays.jl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,7 @@ end
204204
function +(a::Fill{T, 1}, b::AbstractRange) where {T}
205205
size(a) size(b) && throw(DimensionMismatch("dimensions must match."))
206206
Tout = promote_type(T, eltype(b))
207-
return (a.value + first(b)):convert(Tout, step(b)):(a.value + last(b))
208-
end
209-
function +(a::Fill{T, 1}, b::UnitRange) where {T}
210-
size(a) size(b) && throw(DimensionMismatch("dimensions must match."))
211-
Tout = promote_type(T, eltype(b))
212-
return (a.value + first(b)):(a.value + last(b))
207+
return a.value .+ b
213208
end
214209
+(a::AbstractRange, b::AbstractFill) = b + a
215210

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,14 @@ end
694694
@test_throws DimensionMismatch rnge .+ Zeros(5)
695695
@test_throws DimensionMismatch rnge .- Zeros(5)
696696
@test_throws DimensionMismatch Zeros(5) .+ rnge
697+
698+
@test Fill(2,10) + (1:10) isa UnitRange
699+
@test (1:10) + Fill(2,10) isa UnitRange
700+
701+
f = Fill(1+im,10)
702+
@test f + rnge isa AbstractRange
703+
@test f + rnge == rnge + f
704+
@test f + (1:10) isa AbstractRange
697705
end
698706

699707
@testset "Special Zeros/Ones" begin

0 commit comments

Comments
 (0)