Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ jobs:
fail-fast: false
matrix:
version:
- '1.10'
- 'pre'
- 'lts'
- '1'
os:
- ubuntu-latest
- macOS-latest
Expand Down
8 changes: 3 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ version = "0.14.3"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
Infinities = "e1ba4f0e-776d-440f-acd9-e1d2e9742647"
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[weakdeps]
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
Expand Down Expand Up @@ -43,7 +45,3 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "Test", "BandedMatrices", "BlockArrays", "Statistics", "SparseArrays", "Base64", "DSP"]

[weakdeps]
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
13 changes: 3 additions & 10 deletions src/InfiniteArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ import Base: *, +, -, /, <, ==, >, \, ≤, ≥, (:), @propagate_inbounds,
to_shape, transpose, unaliascopy, union, unitrange_last, unsafe_convert, unsafe_indices, unsafe_length,
vcat, zeros

if VERSION < v"1.8-"
import Base: _rangestyle
else
import Base: range_start_step_length
end

import Base: range_start_step_length

if VERSION ≥ v"1.11.0-DEV.21"
using LinearAlgebra: UpperOrLowerTriangular
else
Expand Down Expand Up @@ -210,10 +208,5 @@ end

collect(G::Base.Generator{<:InfRanges}) = BroadcastArray(G.f, G.iter)

if !isdefined(Base, :get_extension)
include("../ext/InfiniteArraysStatisticsExt.jl")
include("../ext/InfiniteArraysDSPExt.jl")
end


end # module
43 changes: 16 additions & 27 deletions src/infrange.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,12 @@
_range(a::AbstractFloat, ::Nothing, ::Nothing, len::InfiniteCardinal{0}) = _range(a, oftype(a, 1), nothing, len)
_range(a::T, st::T, ::Nothing, ::InfiniteCardinal{0}) where T<:IEEEFloat = InfStepRange{T,T}(a, st)
_range(a::T, st::T, ::Nothing, ::InfiniteCardinal{0}) where T<:AbstractFloat = InfStepRange{T,T}(a, st)
if VERSION < v"1.8-"
_rangestyle(::Ordered, ::ArithmeticWraps, a::T, step::S, len::InfiniteCardinal{0}) where {T,S} = InfStepRange{T,S}(a, step)
_rangestyle(::Ordered, ::ArithmeticUnknown, a::T, step::S, len::InfiniteCardinal{0}) where {T,S} = InfStepRange{T,S}(a, step)
_rangestyle(::Any, ::Any, a::T, step::S, len::InfiniteCardinal{0}) where {T,S} = InfStepRange{T,S}(a, step)
else
range_start_step_length(a, st, ::InfiniteCardinal{0}) = InfStepRange(a, st)
range_start_step_length(a::Real, st::IEEEFloat, len::InfiniteCardinal{0}) = range_start_step_length(promote(a, st)..., len)
range_start_step_length(a::IEEEFloat, st::Real, len::InfiniteCardinal{0}) = range_start_step_length(promote(a, st)..., len)
range_start_step_length(a::IEEEFloat, st::IEEEFloat, len::InfiniteCardinal{0}) = range_start_step_length(promote(a, st)..., len)
range_start_step_length(a::T, st::T, ::InfiniteCardinal{0}) where T<:IEEEFloat = InfStepRange{T,T}(a, st)
end
range_start_step_length(a, st, ::InfiniteCardinal{0}) = InfStepRange(a, st)
range_start_step_length(a::Real, st::IEEEFloat, len::InfiniteCardinal{0}) = range_start_step_length(promote(a, st)..., len)
range_start_step_length(a::IEEEFloat, st::Real, len::InfiniteCardinal{0}) = range_start_step_length(promote(a, st)..., len)
range_start_step_length(a::IEEEFloat, st::IEEEFloat, len::InfiniteCardinal{0}) = range_start_step_length(promote(a, st)..., len)

Check warning on line 35 in src/infrange.jl

View check run for this annotation

Codecov / codecov/patch

src/infrange.jl#L35

Added line #L35 was not covered by tests
range_start_step_length(a::T, st::T, ::InfiniteCardinal{0}) where T<:IEEEFloat = InfStepRange{T,T}(a, st)



# Construct range for rational start=start_n/den, step=step_n/den
Expand Down Expand Up @@ -101,16 +96,14 @@
copy(ac::AdjOrTrans{<:Any,<:InfRanges}) = ac
reverse(a::InfRanges) = throw(ArgumentError("Cannot reverse infinite range"))

if VERSION ≥ v"1.7-"
Base.range_start_step_length(a::T, st::T, len::PosInfinity) where T<:Union{Float16,Float32,Float64} = InfStepRange(a, st)
for op in (:+, :-)
@eval $op(a::InfRanges, b::InfRanges) = InfStepRange($op(first(a),first(b)), $op(step(a),step(b)))
end
broadcasted(::DefaultArrayStyle{1}, ::typeof(*), x::Number, r::InfRanges) = InfStepRange(x*first(r), x*step(r))
broadcasted(::DefaultArrayStyle{1}, ::typeof(*), r::InfRanges, x::Number) = InfStepRange(first(r)*x, step(r)*x)
broadcasted(::DefaultArrayStyle{1}, ::typeof(*), x::AbstractFloat, r::InfRanges) = InfStepRange(x*first(r), x*step(r))
broadcasted(::DefaultArrayStyle{1}, ::typeof(*), r::InfRanges, x::AbstractFloat) = InfStepRange(first(r)*x, step(r)*x)
Base.range_start_step_length(a::T, st::T, len::PosInfinity) where T<:Union{Float16,Float32,Float64} = InfStepRange(a, st)

Check warning on line 99 in src/infrange.jl

View check run for this annotation

Codecov / codecov/patch

src/infrange.jl#L99

Added line #L99 was not covered by tests
for op in (:+, :-)
@eval $op(a::InfRanges, b::InfRanges) = InfStepRange($op(first(a),first(b)), $op(step(a),step(b)))
end
broadcasted(::DefaultArrayStyle{1}, ::typeof(*), x::Number, r::InfRanges) = InfStepRange(x*first(r), x*step(r))
broadcasted(::DefaultArrayStyle{1}, ::typeof(*), r::InfRanges, x::Number) = InfStepRange(first(r)*x, step(r)*x)
broadcasted(::DefaultArrayStyle{1}, ::typeof(*), x::AbstractFloat, r::InfRanges) = InfStepRange(x*first(r), x*step(r))
broadcasted(::DefaultArrayStyle{1}, ::typeof(*), r::InfRanges, x::AbstractFloat) = InfStepRange(first(r)*x, step(r)*x)


"""
Expand Down Expand Up @@ -154,9 +147,7 @@
step(r::InfStepRange) = r.step

length(r::InfRanges) = ℵ₀
if VERSION >= v"1.7"
Base.checked_length(r::InfRanges) = ℵ₀
end
Base.checked_length(r::InfRanges) = ℵ₀
unsafe_length(r::InfRanges) = ℵ₀

first(r::OneToInf{T}) where {T} = oneunit(T)
Expand Down Expand Up @@ -604,9 +595,7 @@

FillArrays._range_convert(::Type{AbstractVector{T}}, r::InfRanges) where T = convert(AbstractVector{T}, r)

if VERSION <= v"1.9"
permutedims(D::Diagonal{<:Any,<:InfRanges}) = D
end
permutedims(D::Diagonal{<:Any,<:InfRanges}) = D
copy(D::Diagonal{<:Any,<:InfRanges}) = D
broadcasted(::LazyArrayStyle{2}, ::typeof(*), a::Number, D::Diagonal{<:Any,<:InfRanges}) = a*D
broadcasted(::LazyArrayStyle{2}, ::typeof(*), D::Diagonal{<:Any,<:InfRanges}, a::Number) = D*a
Expand All @@ -629,4 +618,4 @@
# bounds-checking
function Base.checkindex(::Type{Bool}, inds::NTuple{N, AbstractInfUnitRange}, i::AbstractRange{CartesianIndex{N}}) where {N}
isempty(i) | checkindex(Bool, inds, first(i))
end
end
8 changes: 2 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@ end
@test length(2:-.2:-∞) == ℵ₀
@test length(2.:-.2:-∞) == ℵ₀

if VERSION >= v"1.7"
@test Base.checked_length(1:∞) == length(1:∞)
end
@test Base.checked_length(1:∞) == length(1:∞)

@testset "IteratorSize" begin
@test Base.IteratorSize(1:2:∞) == Base.IsInfinite()
Expand Down Expand Up @@ -621,9 +619,7 @@ end
@test D[:,5][1:10] == D[1:10,5]
@test D[5,:][1:10] == D[5,1:10]

if VERSION ≥ v"1.7-"
@test D^2 isa Diagonal
end
@test D^2 isa Diagonal
@test D*D isa Diagonal
@test MemoryLayout(typeof(D.diag)) == LazyLayout()
@test MemoryLayout(typeof(D)) == DiagonalLayout{LazyLayout}()
Expand Down
Loading