Skip to content

Commit

Permalink
feat: add ndims method for ::Type{<:AbstractVectorOfArray}
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Jun 4, 2024
1 parent 805a1cd commit 83bb54f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/vector_of_array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ function Base.check_parent_index_match(
nothing
end
Base.ndims(::AbstractVectorOfArray{T, N}) where {T, N} = N
Base.ndims(::Type{<:AbstractVectorOfArray{T, N}}) where {T, N} = N

Check warning on line 612 in src/vector_of_array.jl

View check run for this annotation

Codecov / codecov/patch

src/vector_of_array.jl#L612

Added line #L612 was not covered by tests

function Base.checkbounds(
::Type{Bool}, VA::AbstractVectorOfArray{T, N, <:AbstractVector{T}},
Expand Down
4 changes: 4 additions & 0 deletions test/interface_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ push!(testda, [-1, -2, -3, -4])
@test testda[:, 9] == [-1, -2, -3, -4]
@test testda[:, end] == [-1, -2, -3, -4]

# ndims
@test ndims(testva) == 2
@test ndims(typeof(testva)) == 2

# Currently we enforce the general shape, they can just be different lengths, ie we
# can't do
# Decide if this is desired, or remove this restriction
Expand Down

0 comments on commit 83bb54f

Please sign in to comment.