We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ce0a06d commit b8753a5Copy full SHA for b8753a5
src/utils.jl
@@ -11,7 +11,7 @@ _strip_IdOffsetRange(r::IdOffsetRange) = parent(r)
11
_strip_IdOffsetRange(r) = r
12
13
_offset(axparent::AbstractUnitRange, ax::AbstractUnitRange) = first(ax) - first(axparent)
14
-_offset(axparent::AbstractUnitRange, ax::Integer) = 1 - first(axparent)
+_offset(axparent::AbstractUnitRange, ::Union{Integer, Colon}) = 1 - first(axparent)
15
16
"""
17
OffsetArrays.AxisConversionStyle(typeof(indices))
test/runtests.jl
@@ -1496,6 +1496,27 @@ end
1496
@test reshape(OffsetArray(-1:0, -1:0), :) == OffsetArray(-1:0, -1:0)
1497
@test reshape(A, :) == reshape(A0, :)
1498
1499
+ # reshape with one Colon for AbstractArrays
1500
+ B = reshape(A0, -10:-9, :)
1501
+ @test B isa OffsetArray{Int,2}
1502
+ @test parent(B) === A0
1503
+ @test axes(B, 1) == -10:-9
1504
+ @test axes(B, 2) == axes(A0, 2)
1505
+
1506
+ B = reshape(A0, -10:-9, 3:3, :)
1507
+ @test B isa OffsetArray{Int,3}
1508
+ @test same_value(A0, B)
1509
1510
+ @test axes(B, 2) == 3:3
1511
+ @test axes(B, 3) == 1:2
1512
1513
+ B = reshape(A0, -10:-9, 3:4, :)
1514
1515
1516
1517
+ @test axes(B, 2) == 3:4
1518
+ @test axes(B, 3) == 1:1
1519
1520
# pop the parent
1521
B = reshape(A, size(A))
1522
@test B == A0
0 commit comments