Skip to content

Commit

Permalink
ListOffsetArray's is_valid.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski committed Aug 8, 2023
1 parent 121825a commit 1891db3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/AwkwardArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ struct ListOffsetArray{T<:Union{Int32,UInt32,Int64}} <: Content
end

function is_valid(x::ListOffsetArray)
true
for i = Base.firstindex(x):Base.lastindex(x)
if x.offsets[i+1] < x.offsets[i]
return false
end
end
return true
end

function Base.length(x::ListOffsetArray)
Expand Down
9 changes: 9 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,13 @@ using Test
end
@test tmp == 5
end

begin
layout = AwkwardArray.ListOffsetArray(
[0, 3, 2, 5],
AwkwardArray.PrimitiveArray([1.1, 2.2, 3.3, 4.4, 5.5]),
)
@test !AwkwardArray.is_valid(layout)
end

end

0 comments on commit 1891db3

Please sign in to comment.