|
1 | 1 | using LinearAlgebra, SparseArrays, InfiniteArrays, FillArrays, LazyArrays, Statistics, DSP, BandedMatrices, LazyBandedMatrices, Test, Base64
|
2 |
| -import InfiniteArrays: OrientedInfinity, SignedInfinity, InfUnitRange, InfStepRange, OneToInf, NotANumber |
| 2 | +import InfiniteArrays: OrientedInfinity, SignedInfinity, InfUnitRange, InfStepRange, OneToInf, NotANumber, oneto, unitrange |
3 | 3 | import LazyArrays: CachedArray, MemoryLayout, LazyLayout, DiagonalLayout, LazyArrayStyle, colsupport, DualLayout
|
4 | 4 | import BandedMatrices: _BandedMatrix, BandedColumns
|
5 | 5 | import Base.Broadcast: broadcasted, Broadcasted, instantiate
|
@@ -42,7 +42,7 @@ import Base.Broadcast: broadcasted, Broadcasted, instantiate
|
42 | 42 |
|
43 | 43 | @test string(∞) == "∞"
|
44 | 44 |
|
45 |
| - @test Base.OneTo(∞) == OneToInf() |
| 45 | + @test oneto(∞) == OneToInf() |
46 | 46 |
|
47 | 47 | @test isinf(∞)
|
48 | 48 | @test !isfinite(∞)
|
@@ -147,8 +147,8 @@ import Base.Broadcast: broadcasted, Broadcasted, instantiate
|
147 | 147 | @test (-∞)*2 ≡ 2*(-∞) ≡ -2 * ∞ ≡ ∞ * (-2) ≡ (-2) * SignedInfinity() ≡ -∞
|
148 | 148 | @test (-∞)*2.3 ≡ 2.3*(-∞) ≡ -2.3 * ∞ ≡ ∞ * (-2.3) ≡ (-2.3) * SignedInfinity() ≡ -∞
|
149 | 149 |
|
150 |
| - @test Base.OneTo(1*∞) == OneToInf() |
151 |
| - @test_throws ArgumentError Base.OneTo(-∞) |
| 150 | + @test oneto(1*∞) == OneToInf() |
| 151 | + @test_throws ArgumentError oneto(-∞) |
152 | 152 |
|
153 | 153 | @test isinf(-∞)
|
154 | 154 | @test !isfinite(-∞)
|
@@ -190,6 +190,8 @@ import Base.Broadcast: broadcasted, Broadcasted, instantiate
|
190 | 190 |
|
191 | 191 | @test exp(im*π/4)*∞ == Inf+im*Inf
|
192 | 192 | @test exp(im*π/4)+∞ == ∞
|
| 193 | + |
| 194 | + @test_throws ArgumentError oneto(exp(im*π/4)*∞) |
193 | 195 | end
|
194 | 196 | end
|
195 | 197 |
|
|
234 | 236 | @test similar(a, Float64, ∞) isa CachedArray{Float64}
|
235 | 237 | @test similar(a, Float64, (∞,)) isa CachedArray{Float64}
|
236 | 238 | @test similar(a, Float64, (∞,∞)) isa CachedArray{Float64}
|
237 |
| - @test similar(a, Float64, Base.OneTo(∞)) isa CachedArray{Float64} |
238 |
| - @test similar(a, Float64, (Base.OneTo(∞),)) isa CachedArray{Float64} |
239 |
| - @test similar(a, Float64, (Base.OneTo(∞),Base.OneTo(∞))) isa CachedArray{Float64} |
| 239 | + @test similar(a, Float64, oneto(∞)) isa CachedArray{Float64} |
| 240 | + @test similar(a, Float64, (oneto(∞),)) isa CachedArray{Float64} |
| 241 | + @test similar(a, Float64, (oneto(∞),oneto(∞))) isa CachedArray{Float64} |
240 | 242 |
|
241 | 243 | @test similar([1,2,3],Float64,()) isa Array{Float64,0}
|
242 | 244 |
|
|
443 | 445 | end
|
444 | 446 |
|
445 | 447 | @testset "Base.OneTo (misleading) overrides" begin
|
446 |
| - @test Base.OneTo{BigInt}(∞) isa OneToInf{BigInt} |
447 |
| - @test Base.OneTo(∞) isa OneToInf{Int} |
| 448 | + @test_skip Base.OneTo{BigInt}(∞) isa OneToInf{BigInt} |
| 449 | + @test oneto(∞) isa OneToInf{Int} |
448 | 450 | end
|
449 | 451 |
|
450 | 452 | @testset "issue #6973" begin
|
|
501 | 503 |
|
502 | 504 | @test AbstractArray{Float64}(1:2:∞) ≡ AbstractVector{Float64}(1:2:∞) ≡
|
503 | 505 | convert(AbstractVector{Float64}, 1:2:∞) ≡ convert(AbstractArray{Float64}, 1:2:∞)
|
| 506 | + |
| 507 | + @test unitrange(oneto(∞)) ≡ InfUnitRange(oneto(∞)) ≡ InfUnitRange{Int}(oneto(∞)) ≡ InfUnitRange(1) |
504 | 508 | end
|
505 | 509 |
|
506 | 510 | @testset "inf-range[inf-range]" begin
|
|
545 | 549 | end
|
546 | 550 |
|
547 | 551 | @testset "end" begin
|
548 |
| - @test Base.OneTo(∞)[end] ≡ Base.OneTo(∞)[∞] ≡ ∞ |
| 552 | + @test oneto(∞)[end] ≡ oneto(∞)[∞] ≡ ∞ |
549 | 553 | @test (1:∞)[end] ≡ (1:∞)[∞] ≡ ∞
|
550 | 554 | @test (1:2:∞)[end] ≡ (1:2:∞)[∞] ≡ ∞
|
551 | 555 | @test (1.0:2:∞)[end] ≡ (1.0:2:∞)[∞] ≡ ∞
|
@@ -834,10 +838,10 @@ end
|
834 | 838 | @testset "Cumsum and diff" begin
|
835 | 839 | @test cumsum(Ones(∞)) ≡ 1.0:1.0:∞
|
836 | 840 | @test cumsum(Fill(2,∞)) ≡ 2:2:∞
|
837 |
| - @test cumsum(Ones{Int}(∞)) ≡ Base.OneTo(∞) |
838 |
| - @test cumsum(Ones{BigInt}(∞)) ≡ Base.OneTo{BigInt}(∞) |
| 841 | + @test cumsum(Ones{Int}(∞)) ≡ oneto(∞) |
| 842 | + @test cumsum(Ones{BigInt}(∞)) ≡ OneToInf{BigInt}() |
839 | 843 |
|
840 |
| - @test diff(Base.OneTo(∞)) ≡ Ones{Int}(∞) |
| 844 | + @test diff(oneto(∞)) ≡ Ones{Int}(∞) |
841 | 845 | @test diff(1:∞) ≡ Fill(1,∞)
|
842 | 846 | @test diff(1:2:∞) ≡ Fill(2,∞)
|
843 | 847 | @test diff(1:2.0:∞) ≡ Fill(2.0,∞)
|
|
853 | 857 | @test cumsum(x).args[2] ≡ 8:12
|
854 | 858 | @test last(y.args) == sum(x[1:9]):2:∞
|
855 | 859 |
|
856 |
| - for r in (3:4:∞, 2:∞, Base.OneTo(∞)) |
| 860 | + for r in (3:4:∞, 2:∞, oneto(∞)) |
857 | 861 | c = cumsum(r)
|
858 | 862 | @test c isa InfiniteArrays.RangeCumsum
|
859 | 863 | @test c[Base.OneTo(20)] == c[1:20] == [c[k] for k=1:20] == cumsum(r[1:20])
|
|
877 | 881 | @test conv(1:2:∞, [2]) ≡ conv([2], 1:2:∞) ≡ 2:4:∞
|
878 | 882 | @test conv(1:∞, Ones(∞))[1:5] == conv(Ones(∞),1:∞)[1:5] == [1,3,6,10,15]
|
879 | 883 | @test conv(Ones(∞), Ones(∞)) ≡ 1.0:1.0:∞
|
880 |
| - @test conv(Ones{Int}(∞), Ones{Int}(∞)) ≡ Base.OneTo(∞) |
881 |
| - @test conv(Ones{Bool}(∞), Ones{Bool}(∞)) ≡ Base.OneTo(∞) |
| 884 | + @test conv(Ones{Int}(∞), Ones{Int}(∞)) ≡ oneto(∞) |
| 885 | + @test conv(Ones{Bool}(∞), Ones{Bool}(∞)) ≡ oneto(∞) |
882 | 886 | @test conv(Fill{Int}(2,∞), Fill{Int}(1,∞)) ≡ conv(Fill{Int}(2,∞), Ones{Int}(∞)) ≡
|
883 | 887 | conv(Ones{Int}(∞), Fill{Int}(2,∞)) ≡ 2:2:∞
|
884 | 888 | @test conv(Ones{Int}(∞), [1,5,8])[1:10] == conv([1,5,8], Ones{Int}(∞))[1:10] ==
|
@@ -1008,21 +1012,21 @@ end
|
1008 | 1012 | end
|
1009 | 1013 |
|
1010 | 1014 | @testset "convert infrange" begin
|
1011 |
| - @test convert(AbstractArray{Float64}, 1:∞) ≡ convert(AbstractArray{Float64}, Base.OneTo(∞)) ≡ |
1012 |
| - convert(AbstractVector{Float64}, 1:∞) ≡ convert(AbstractVector{Float64}, Base.OneTo(∞)) ≡ |
1013 |
| - AbstractVector{Float64}(1:∞) ≡ AbstractVector{Float64}(Base.OneTo(∞)) ≡ |
1014 |
| - AbstractArray{Float64}(1:∞) ≡ AbstractArray{Float64}(Base.OneTo(∞)) ≡ InfUnitRange(1.0) |
1015 |
| - |
1016 |
| - @test convert(AbstractArray{Float64}, (1:∞)') ≡ convert(AbstractArray{Float64}, Base.OneTo(∞)') ≡ |
1017 |
| - convert(AbstractMatrix{Float64}, (1:∞)') ≡ convert(AbstractMatrix{Float64}, Base.OneTo(∞)') ≡ |
1018 |
| - AbstractMatrix{Float64}((1:∞)') ≡ AbstractMatrix{Float64}(Base.OneTo(∞)') ≡ |
1019 |
| - AbstractArray{Float64}((1:∞)') ≡ AbstractArray{Float64}(Base.OneTo(∞)') ≡ |
| 1015 | + @test convert(AbstractArray{Float64}, 1:∞) ≡ convert(AbstractArray{Float64}, oneto(∞)) ≡ |
| 1016 | + convert(AbstractVector{Float64}, 1:∞) ≡ convert(AbstractVector{Float64}, oneto(∞)) ≡ |
| 1017 | + AbstractVector{Float64}(1:∞) ≡ AbstractVector{Float64}(oneto(∞)) ≡ |
| 1018 | + AbstractArray{Float64}(1:∞) ≡ AbstractArray{Float64}(oneto(∞)) ≡ InfUnitRange(1.0) |
| 1019 | + |
| 1020 | + @test convert(AbstractArray{Float64}, (1:∞)') ≡ convert(AbstractArray{Float64}, oneto(∞)') ≡ |
| 1021 | + convert(AbstractMatrix{Float64}, (1:∞)') ≡ convert(AbstractMatrix{Float64}, oneto(∞)') ≡ |
| 1022 | + AbstractMatrix{Float64}((1:∞)') ≡ AbstractMatrix{Float64}(oneto(∞)') ≡ |
| 1023 | + AbstractArray{Float64}((1:∞)') ≡ AbstractArray{Float64}(oneto(∞)') ≡ |
1020 | 1024 | InfUnitRange(1.0)'
|
1021 | 1025 |
|
1022 |
| - @test convert(AbstractArray{Float64}, transpose(1:∞)) ≡ convert(AbstractArray{Float64}, transpose(Base.OneTo(∞))) ≡ |
1023 |
| - convert(AbstractMatrix{Float64}, transpose(1:∞)) ≡ convert(AbstractMatrix{Float64}, transpose(Base.OneTo(∞))) ≡ |
1024 |
| - AbstractMatrix{Float64}(transpose(1:∞)) ≡ AbstractMatrix{Float64}(transpose(Base.OneTo(∞))) ≡ |
1025 |
| - AbstractArray{Float64}(transpose(1:∞)) ≡ AbstractArray{Float64}(transpose(Base.OneTo(∞))) ≡ |
| 1026 | + @test convert(AbstractArray{Float64}, transpose(1:∞)) ≡ convert(AbstractArray{Float64}, transpose(oneto(∞))) ≡ |
| 1027 | + convert(AbstractMatrix{Float64}, transpose(1:∞)) ≡ convert(AbstractMatrix{Float64}, transpose(oneto(∞))) ≡ |
| 1028 | + AbstractMatrix{Float64}(transpose(1:∞)) ≡ AbstractMatrix{Float64}(transpose(oneto(∞))) ≡ |
| 1029 | + AbstractArray{Float64}(transpose(1:∞)) ≡ AbstractArray{Float64}(transpose(oneto(∞))) ≡ |
1026 | 1030 | transpose(InfUnitRange(1.0))
|
1027 | 1031 | end
|
1028 | 1032 |
|
|
0 commit comments