Skip to content

Commit

Permalink
Fix addition of complex-valued Fill and ranges (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty authored Oct 11, 2021
1 parent a8bffd3 commit aeb0aef
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "FillArrays"
uuid = "1a297f60-69ca-5386-bcde-b61e274b549b"
version = "0.12.6"
version = "0.12.7"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
7 changes: 1 addition & 6 deletions src/FillArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,7 @@ end
function +(a::Fill{T, 1}, b::AbstractRange) where {T}
size(a) size(b) && throw(DimensionMismatch("dimensions must match."))
Tout = promote_type(T, eltype(b))
return (a.value + first(b)):convert(Tout, step(b)):(a.value + last(b))
end
function +(a::Fill{T, 1}, b::UnitRange) where {T}
size(a) size(b) && throw(DimensionMismatch("dimensions must match."))
Tout = promote_type(T, eltype(b))
return (a.value + first(b)):(a.value + last(b))
return a.value .+ b
end
+(a::AbstractRange, b::AbstractFill) = b + a

Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,14 @@ end
@test_throws DimensionMismatch rnge .+ Zeros(5)
@test_throws DimensionMismatch rnge .- Zeros(5)
@test_throws DimensionMismatch Zeros(5) .+ rnge

@test Fill(2,10) + (1:10) isa UnitRange
@test (1:10) + Fill(2,10) isa UnitRange

f = Fill(1+im,10)
@test f + rnge isa AbstractRange
@test f + rnge == rnge + f
@test f + (1:10) isa AbstractRange
end

@testset "Special Zeros/Ones" begin
Expand Down

2 comments on commit aeb0aef

@dlfivefifty
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/46483

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.12.7 -m "<description of version>" aeb0aef1060a8da0df2d3b711b2b43842d982901
git push origin v0.12.7

Please sign in to comment.