|
150 | 150 | @test bpart == blockedrange(2, 1:0) |
151 | 151 |
|
152 | 152 | o = OffsetArray([2,2,3],-1:1) |
153 | | - b = blockedrange(1, o) |
154 | | - @test axes(b) == (b,) |
155 | | - @test @inferred(b[Block(-1)]) == 1:2 |
156 | | - @test b[Block(0)] == 3:4 |
157 | | - @test b[Block(1)] == 5:7 |
158 | | - @test_throws BlockBoundsError b[Block(-2)] |
159 | | - @test_throws BlockBoundsError b[Block(2)] |
| 153 | + @test_throws ArgumentError blockedrange(1, o) |
160 | 154 |
|
161 | 155 | b = BlockArrays._BlockedUnitRange(-1,[-1,1,4]) |
162 | 156 | @test axes(b,1) == blockedrange(1, [1,2,3]) |
|
166 | 160 | @test_throws BlockBoundsError b[Block(0)] |
167 | 161 | @test_throws BlockBoundsError b[Block(4)] |
168 | 162 |
|
169 | | - o = OffsetArray([2,2,3],-1:1) |
170 | | - b = BlockArrays._BlockedUnitRange(-3, cumsum(o) .- 4) |
171 | | - @test axes(b,1) == blockedrange(1, [2,2,3]) |
172 | | - @test b[Block(-1)] == -3:-2 |
173 | | - @test b[Block(0)] == -1:0 |
174 | | - @test b[Block(1)] == 1:3 |
175 | | - @test_throws BlockBoundsError b[Block(-2)] |
176 | | - @test_throws BlockBoundsError b[Block(2)] |
177 | | - |
178 | 163 | b = BlockArrays._BlockedUnitRange(1, cumsum(Fill(3,1_000_000))) |
179 | 164 | @test b isa BlockedUnitRange{<:AbstractRange} |
180 | 165 | @test b[Block(100_000)] == 299_998:300_000 |
|
249 | 234 | @test_throws BoundsError findblockindex(b,0) |
250 | 235 | @test_throws BoundsError findblockindex(b,7) |
251 | 236 |
|
252 | | - o = OffsetArray([2,2,3],-1:1) |
253 | | - b = blockedrange(1, o) |
254 | | - @test @inferred(findblock(b,1)) == Block(-1) |
255 | | - @test @inferred(findblockindex(b,1)) == Block(-1)[1] |
256 | | - @test findblock.(Ref(b),1:7) == Block.([-1,-1,0,0,1,1,1]) |
257 | | - @test findblockindex.(Ref(b),1:7) == BlockIndex.([-1,-1,0,0,1,1,1], [1,2,1,2,1,2,3]) |
258 | | - @test_throws BoundsError findblock(b,0) |
259 | | - @test_throws BoundsError findblock(b,8) |
260 | | - @test_throws BoundsError findblockindex(b,0) |
261 | | - @test_throws BoundsError findblockindex(b,8) |
262 | | - |
263 | 237 | b = BlockArrays._BlockedUnitRange(-1,[-1,1,4]) |
264 | 238 | @test @inferred(findblock(b,-1)) == Block(1) |
265 | 239 | @test @inferred(findblockindex(b,-1)) == Block(1)[1] |
|
270 | 244 | @test_throws BoundsError findblockindex(b,-2) |
271 | 245 | @test_throws BoundsError findblockindex(b,5) |
272 | 246 |
|
273 | | - o = OffsetArray([2,2,3],-1:1) |
274 | | - b = BlockArrays._BlockedUnitRange(-3, cumsum(o) .- 4) |
275 | | - @test @inferred(findblock(b,-3)) == Block(-1) |
276 | | - @test @inferred(findblockindex(b,-3)) == Block(-1)[1] |
277 | | - @test findblock.(Ref(b),-3:3) == Block.([-1,-1,0,0,1,1,1]) |
278 | | - @test findblockindex.(Ref(b),-3:3) == BlockIndex.([-1,-1,0,0,1,1,1], [1,2,1,2,1,2,3]) |
279 | | - @test_throws BoundsError findblock(b,-4) |
280 | | - @test_throws BoundsError findblock(b,5) |
281 | | - @test_throws BoundsError findblockindex(b,-4) |
282 | | - @test_throws BoundsError findblockindex(b,5) |
283 | | - |
284 | 247 | b = blockedrange(1, Fill(3,1_000_000)) |
285 | 248 | @test @inferred(findblock(b, 1)) == Block(1) |
286 | 249 | @test @inferred(findblockindex(b, 1)) == Block(1)[1] |
@@ -425,32 +388,14 @@ end |
425 | 388 | @test_throws BlockBoundsError b[Block(4)] |
426 | 389 | @test_throws BlockBoundsError view(b, Block(4)) |
427 | 390 |
|
428 | | - o = OffsetArray([2,2,3],-1:1) |
429 | | - b = blockedrange(o) |
430 | | - @test axes(b) == (b,) |
431 | | - @test @inferred(b[Block(-1)]) == 1:2 |
432 | | - @test b[Block(0)] == 3:4 |
433 | | - @test b[Block(1)] == 5:7 |
434 | | - @test_throws BlockBoundsError b[Block(-2)] |
435 | | - @test_throws BlockBoundsError b[Block(2)] |
436 | | - |
437 | | - b = BlockArrays._BlockedUnitRange(-1,[-1,1,4]) |
438 | | - @test axes(b,1) == blockedrange([1,2,3]) |
439 | | - @test b[Block(1)] == -1:-1 |
440 | | - @test b[Block(2)] == 0:1 |
| 391 | + b = BlockedOneTo([0,1,4]) |
| 392 | + @test axes(b,1) == blockedrange([0,1,3]) |
| 393 | + @test b[Block(1)] == 1:0 |
| 394 | + @test b[Block(2)] == 1:1 |
441 | 395 | @test b[Block(3)] == 2:4 |
442 | 396 | @test_throws BlockBoundsError b[Block(0)] |
443 | 397 | @test_throws BlockBoundsError b[Block(4)] |
444 | 398 |
|
445 | | - o = OffsetArray([2,2,3],-1:1) |
446 | | - b = BlockArrays._BlockedUnitRange(-3, cumsum(o) .- 4) |
447 | | - @test axes(b,1) == blockedrange([2,2,3]) |
448 | | - @test b[Block(-1)] == -3:-2 |
449 | | - @test b[Block(0)] == -1:0 |
450 | | - @test b[Block(1)] == 1:3 |
451 | | - @test_throws BlockBoundsError b[Block(-2)] |
452 | | - @test_throws BlockBoundsError b[Block(2)] |
453 | | - |
454 | 399 | b = blockedrange(1,Fill(3,1_000_000)) |
455 | 400 | @test b isa BlockedUnitRange{<:AbstractRange} |
456 | 401 | @test b[Block(100_000)] == 299_998:300_000 |
|
565 | 510 | end |
566 | 511 |
|
567 | 512 | b = blockedrange(1:3) |
568 | | - @test bpart isa BlockedUnitRange |
569 | 513 | bpart = @inferred(b[Block.(1:2)]) |
| 514 | + @test bpart isa BlockedUnitRange |
570 | 515 | @test bpart == blockedrange(1:2) |
571 | 516 | bpart = @inferred(b[Block.(1:0)]) |
572 | 517 | @test bpart isa BlockedUnitRange |
|
0 commit comments