diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a6da199..cd472dea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,9 @@ name: CI on: - - push - - pull_request + push: + branches: + - master + pull_request: jobs: test: name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} @@ -12,7 +14,7 @@ jobs: version: - '1.6' - '1' - - '^1.7.0-0' + - '^1.8.0-0' os: - ubuntu-latest - macOS-latest diff --git a/Project.toml b/Project.toml index c5e6bac4..25ffbaf6 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "FillArrays" uuid = "1a297f60-69ca-5386-bcde-b61e274b549b" -version = "0.13.0" +version = "0.13.1" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/src/fillbroadcast.jl b/src/fillbroadcast.jl index a26d5204..646ffd7a 100644 --- a/src/fillbroadcast.jl +++ b/src/fillbroadcast.jl @@ -197,21 +197,26 @@ function broadcasted(::DefaultArrayStyle{1}, ::typeof(*), a::AbstractRange{V}, b return _range_convert(AbstractVector{promote_type(T,V)}, a) end +_copy_oftype(A::AbstractArray{T,N}, ::Type{T}) where {T,N} = copy(A) +_copy_oftype(A::AbstractArray{T,N}, ::Type{S}) where {T,N,S} = convert(AbstractArray{S,N}, A) +_copy_oftype(A::AbstractRange{T}, ::Type{T}) where T = copy(A) +_copy_oftype(A::AbstractRange{T}, ::Type{S}) where {T,S} = map(S, A) + for op in (:+, -) @eval begin function broadcasted(::DefaultArrayStyle{1}, ::typeof($op), a::AbstractVector{T}, b::Zeros{V,1}) where {T,V} broadcast_shape(axes(a), axes(b)) == axes(a) || throw(ArgumentError("Cannot broadcast $a and $b. Convert $b to a Vector first.")) - LinearAlgebra.copy_oftype(a, promote_type(T,V)) + _copy_oftype(a, promote_type(T,V)) end - broadcasted(::DefaultArrayStyle{1}, ::typeof($op), a::AbstractFill{T,1}, b::Zeros{V,1}) where {T,V} = + broadcasted(::DefaultArrayStyle{1}, ::typeof($op), a::AbstractFill{T,1}, b::Zeros{V,1}) where {T,V} = Base.invoke(broadcasted, Tuple{DefaultArrayStyle, typeof($op), AbstractFill, AbstractFill}, DefaultArrayStyle{1}(), $op, a, b) end end function broadcasted(::DefaultArrayStyle{1}, ::typeof(+), a::Zeros{T,1}, b::AbstractVector{V}) where {T,V} broadcast_shape(axes(a), axes(b)) - LinearAlgebra.copy_oftype(b, promote_type(T,V)) + _copy_oftype(b, promote_type(T,V)) end broadcasted(::DefaultArrayStyle{1}, ::typeof(+), a::Zeros{V,1}, b::AbstractFill{T,1}) where {T,V} = diff --git a/test/runtests.jl b/test/runtests.jl index 759934f6..1ef5e605 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1053,8 +1053,8 @@ end @test copy(m) ≡ m @test copy(D) ≡ D - @test LinearAlgebra.copy_oftype(m, Int) ≡ Eye{Int}(10) - @test LinearAlgebra.copy_oftype(D, Float64) ≡ Diagonal(Fill(2.0,10)) + @test FillArrays._copy_oftype(m, Int) ≡ Eye{Int}(10) + @test FillArrays._copy_oftype(D, Float64) ≡ Diagonal(Fill(2.0,10)) end @testset "Issue #31" begin