|
1 | 1 | using OffsetArrays |
2 | 2 | using OffsetArrays: IdentityUnitRange, no_offset_view |
| 3 | +using OffsetArrays: IdOffsetRange |
3 | 4 | using Test, Aqua |
4 | 5 | using LinearAlgebra |
5 | 6 | using DelimitedFiles |
|
125 | 126 | w = zeros(5:6) |
126 | 127 | @test OffsetVector(w, :) == OffsetArray(w, (:,)) == OffsetArray(w, :) == OffsetArray(w, axes(w)) |
127 | 128 | @test axes(OffsetVector(w, :)) == axes(w) |
| 129 | + |
| 130 | + @test axes(OffsetVector(v, typemax(Int)-length(v))) == (IdOffsetRange(axes(v)[1], typemax(Int)-length(v)), ) |
| 131 | + @test_throws ArgumentError OffsetVector(v, typemax(Int)-length(v)+1) |
| 132 | + ao = OffsetArray(v, typemin(Int)) |
| 133 | + @test_nowarn OffsetArray{Float64, 1, typeof(ao)}(ao, (-1, )) |
| 134 | + @test_throws ArgumentError OffsetArray{Float64, 1, typeof(ao)}(ao, (-2, )) # inner Constructor |
| 135 | + @test_throws ArgumentError OffsetArray(ao, (-2, )) # convinient constructor accumulate offsets |
128 | 136 | end |
129 | 137 |
|
130 | 138 | @testset "OffsetMatrix constructors" begin |
|
158 | 166 |
|
159 | 167 | @test axes(OffsetMatrix(w, :, CartesianIndices((0:1,)))) == (3:4, 0:1) |
160 | 168 | @test axes(OffsetMatrix(w, CartesianIndices((0:1,)), :)) == (0:1, 5:6) |
| 169 | + |
| 170 | + @test axes(OffsetMatrix(v, typemax(Int)-size(v, 1), 0)) == (IdOffsetRange(axes(v)[1], typemax(Int)-size(v, 1)), axes(v, 2)) |
| 171 | + @test_throws ArgumentError OffsetMatrix(v, typemax(Int)-size(v,1)+1, 0) |
| 172 | + @test_throws ArgumentError OffsetMatrix(v, 0, typemax(Int)-size(v, 2)+1) |
161 | 173 | end |
162 | 174 |
|
163 | 175 | @testset "construct OffsetArray with CartesianIndices" begin |
|
0 commit comments