Skip to content

Commit db1023a

Browse files
committed
Add length method for ViewAxis
1 parent 0d9d5d2 commit db1023a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/axis.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ ViewAxis{Inds,IdxMap,Ax}() where {Inds,IdxMap,Ax} = ViewAxis(Inds, Ax())
122122
ViewAxis(Inds, IdxMap) = ViewAxis(Inds, Axis(IdxMap))
123123
ViewAxis(Inds) = Inds
124124

125+
Base.length(ax::ViewAxis{Inds}) where Inds = length(Inds)
126+
125127
const View = ViewAxis
126128
const NullOrFlatView{Inds,IdxMap} = ViewAxis{Inds,IdxMap,<:NullorFlatAxis}
127129

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ end
178178
x = ComponentArray(b=1, a=2)
179179
@test merge(NamedTuple(), x) == NamedTuple(x)
180180
@test kw_fun(; x...) == 2
181+
182+
@test length(ViewAxis(2:7, ShapedAxis((2,3)))) == 6
181183
end
182184

183185
@testset "Get" begin
@@ -388,6 +390,8 @@ end
388390
end
389391
end
390392

393+
394+
391395
@testset "Similar" begin
392396
@test similar(ca) isa typeof(ca)
393397
@test similar(ca2) isa typeof(ca2)

0 commit comments

Comments
 (0)