From 4d7c35ebd7b588d87e032ae5acaef4a49a86c304 Mon Sep 17 00:00:00 2001 From: Tianyi Pu <912396513@qq.com> Date: Wed, 15 Mar 2023 23:41:22 +0000 Subject: [PATCH 1/5] support +/- AbstractFill from FillArrays --- src/InfiniteArrays.jl | 2 +- src/infrange.jl | 13 ++++++++----- test/runtests.jl | 16 +++++++++++++--- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/InfiniteArrays.jl b/src/InfiniteArrays.jl index abf3a8c..42d5f7b 100644 --- a/src/InfiniteArrays.jl +++ b/src/InfiniteArrays.jl @@ -43,7 +43,7 @@ import LinearAlgebra: BlasInt, BlasFloat, norm, diag, diagm, ishermitian, issymm import Statistics: mean, median -import FillArrays: AbstractFill, getindex_value, fill_reshape, RectDiagonal, Fill, Ones, Zeros, Eye +import FillArrays: AbstractFill, getindex_value, fill_reshape, RectDiagonal, Fill, Ones, Zeros, Eye, elconvert import LazyArrays: LazyArrayStyle, AbstractBandedLayout, MemoryLayout, LazyLayout, UnknownLayout, ZerosLayout, AbstractCachedVector, CachedArray, CachedVector, ApplyLayout, LazyMatrix, reshapedlayout, sub_materialize, sublayout, LayoutMatrix, LayoutVector, _padded_sub_materialize, PaddedLayout, diff --git a/src/infrange.jl b/src/infrange.jl index ce4cf1e..fa29973 100644 --- a/src/infrange.jl +++ b/src/infrange.jl @@ -75,16 +75,19 @@ struct InfUnitRange{T<:Real} <: AbstractInfUnitRange{T} start::T end - InfUnitRange(a::InfUnitRange) = a InfUnitRange{T}(a::AbstractInfUnitRange) where T<:Real = InfUnitRange{T}(first(a)) InfUnitRange(a::AbstractInfUnitRange{T}) where T<:Real = InfUnitRange{T}(first(a)) unitrange(a::AbstractInfUnitRange) = InfUnitRange(a) -AbstractArray{T}(a::InfUnitRange) where T<:Real = InfUnitRange{T}(a.start) -AbstractVector{T}(a::InfUnitRange) where T<:Real = InfUnitRange{T}(a.start) +for TYPE in (:AbstractArray, :AbstractVector) + @eval $TYPE{T}(a::InfUnitRange) where T<:Integer = InfUnitRange{T}(a.start) + @eval $TYPE{T}(a::InfUnitRange) where T = InfStepRange(T(a.start), one(T)) +end AbstractArray{T}(a::InfStepRange) where T<:Real = InfStepRange(convert(T,a.start), convert(T,a.step)) AbstractVector{T}(a::InfStepRange) where T<:Real = InfStepRange(convert(T,a.start), convert(T,a.step)) +elconvert(::Type{T}, r::AbstractInfUnitRange) where T = AbstractArray{T}(r) +elconvert(::Type{T}, r::InfStepRange) where T = AbstractArray{T}(r) const InfRanges{T} = Union{InfStepRange{T},AbstractInfUnitRange{T}} const InfAxes = Union{InfRanges{<:Integer},Slice{<:AbstractInfUnitRange{<:Integer}},IdentityUnitRange{<:AbstractInfUnitRange{<:Integer}}} @@ -133,8 +136,8 @@ function oneto(x::ComplexInfinity) AbstractArray{T}(a::OneToInf) where T<:Integer = OneToInf{T}() AbstractVector{T}(a::OneToInf) where T<:Integer = OneToInf{T}() -AbstractArray{T}(a::OneToInf) where T<:Real = InfUnitRange{T}(a) -AbstractVector{T}(a::OneToInf) where T<:Real = InfUnitRange{T}(a) +AbstractArray{T}(a::OneToInf) where T<:Real = InfStepRange(one(T),one(T)) +AbstractVector{T}(a::OneToInf) where T<:Real = InfStepRange(one(T),one(T)) (==)(::OneToInf, ::OneToInf) = true diff --git a/test/runtests.jl b/test/runtests.jl index 7e52145..969e736 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -520,6 +520,12 @@ end @test sum([1; zeros(∞)]) ≡ 1.0 @test sum([1; ones(∞)]) ≡ 1.0∞ end + + @testset "fill algebra" begin + @test zeros(∞) + (1:∞) ≡ 1.0:∞ + @test ones(∞) + (1:∞) ≡ 2.0:∞ + @test zeros(∞) - (1:∞) ≡ -1.0:-1.0:-∞ + end end @testset "diagonal" begin @@ -1002,19 +1008,23 @@ end @test convert(AbstractArray{Float64}, 1:∞) ≡ convert(AbstractArray{Float64}, oneto(∞)) ≡ convert(AbstractVector{Float64}, 1:∞) ≡ convert(AbstractVector{Float64}, oneto(∞)) ≡ AbstractVector{Float64}(1:∞) ≡ AbstractVector{Float64}(oneto(∞)) ≡ - AbstractArray{Float64}(1:∞) ≡ AbstractArray{Float64}(oneto(∞)) ≡ InfUnitRange(1.0) + AbstractArray{Float64}(1:∞) ≡ AbstractArray{Float64}(oneto(∞)) ≡ + float(1:∞) ≡ float(oneto(∞)) ≡ + 1.0:∞ @test convert(AbstractArray{Float64}, (1:∞)') ≡ convert(AbstractArray{Float64}, oneto(∞)') ≡ convert(AbstractMatrix{Float64}, (1:∞)') ≡ convert(AbstractMatrix{Float64}, oneto(∞)') ≡ AbstractMatrix{Float64}((1:∞)') ≡ AbstractMatrix{Float64}(oneto(∞)') ≡ AbstractArray{Float64}((1:∞)') ≡ AbstractArray{Float64}(oneto(∞)') ≡ - InfUnitRange(1.0)' + float((1:∞)') ≡ float(oneto(∞)') ≡ + (1.0:∞)' @test convert(AbstractArray{Float64}, transpose(1:∞)) ≡ convert(AbstractArray{Float64}, transpose(oneto(∞))) ≡ convert(AbstractMatrix{Float64}, transpose(1:∞)) ≡ convert(AbstractMatrix{Float64}, transpose(oneto(∞))) ≡ AbstractMatrix{Float64}(transpose(1:∞)) ≡ AbstractMatrix{Float64}(transpose(oneto(∞))) ≡ AbstractArray{Float64}(transpose(1:∞)) ≡ AbstractArray{Float64}(transpose(oneto(∞))) ≡ - transpose(InfUnitRange(1.0)) + float(transpose(1:∞)) ≡ float(transpose(oneto(∞))) ≡ + transpose(1.0:∞) end @testset "cached indexing" begin From a4a78913c7eb452d0bd4858429d6e4a5745a13ca Mon Sep 17 00:00:00 2001 From: Tianyi Pu <912396513@qq.com> Date: Thu, 16 Mar 2023 14:34:33 +0000 Subject: [PATCH 2/5] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 1bc605b..25d4470 100644 --- a/Project.toml +++ b/Project.toml @@ -13,7 +13,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [compat] Aqua = "0.5" ArrayLayouts = "0.8" -FillArrays = "0.13" +FillArrays = "0.13.8" Infinities = "0.1.1" LazyArrays = "0.22.13" julia = "1.6" From 34ce62bd37cf9d7d411c92f81c51c553077fe0bb Mon Sep 17 00:00:00 2001 From: Tianyi Pu <912396513@qq.com> Date: Thu, 16 Mar 2023 17:18:52 +0000 Subject: [PATCH 3/5] try to re-run action --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c6bdf20..d435d73 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # InfiniteArrays.jl - + [![Build Status](https://github.com/JuliaArrays/InfiniteArrays.jl/workflows/CI/badge.svg)](https://github.com/JuliaArrays/InfiniteArrays.jl/actions) [![codecov](https://codecov.io/gh/JuliaArrays/InfiniteArrays.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaArrays/InfiniteArrays.jl) From 9a3bc2a484f4c1f506da6d3edba0f664099f7bba Mon Sep 17 00:00:00 2001 From: Tianyi Pu <912396513@qq.com> Date: Thu, 16 Mar 2023 17:24:16 +0000 Subject: [PATCH 4/5] fix --- test/runtests.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 969e736..95e7507 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -522,9 +522,9 @@ end end @testset "fill algebra" begin - @test zeros(∞) + (1:∞) ≡ 1.0:∞ - @test ones(∞) + (1:∞) ≡ 2.0:∞ - @test zeros(∞) - (1:∞) ≡ -1.0:-1.0:-∞ + @test Zeros(∞) + (1:∞) ≡ 1.0:∞ + @test Ones(∞) + (1:∞) ≡ 2.0:∞ + @test Zeros(∞) - (1:∞) ≡ -1.0:-1.0:-∞ end end From f3b81d13287517cac5a0a6663c10a14baad14b9e Mon Sep 17 00:00:00 2001 From: Tianyi Pu <912396513@qq.com> Date: Thu, 16 Mar 2023 18:15:32 +0000 Subject: [PATCH 5/5] Revert "try to re-run action" This reverts commit 34ce62bd37cf9d7d411c92f81c51c553077fe0bb. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d435d73..c6bdf20 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # InfiniteArrays.jl - + [![Build Status](https://github.com/JuliaArrays/InfiniteArrays.jl/workflows/CI/badge.svg)](https://github.com/JuliaArrays/InfiniteArrays.jl/actions) [![codecov](https://codecov.io/gh/JuliaArrays/InfiniteArrays.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaArrays/InfiniteArrays.jl)