Skip to content

Commit

Permalink
Merge pull request #164 from Pangoraw/main
Browse files Browse the repository at this point in the history
Add `firstindex(::AbstractDataContainer)`
  • Loading branch information
ToucheSir authored Aug 26, 2023
2 parents 03f8fb1 + 619ef01 commit 3a7d3e3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/observation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ Base.size(x::AbstractDataContainer) = (numobs(x),)
Base.iterate(x::AbstractDataContainer, state = 1) =
(state > numobs(x)) ? nothing : (getobs(x, state), state + 1)
Base.lastindex(x::AbstractDataContainer) = numobs(x)
Base.firstindex(::AbstractDataContainer) = 1

# --------------------------------------------------------------------
# Arrays
Expand Down
2 changes: 2 additions & 0 deletions test/obsview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
@test @inferred(getobs(subset)) == getobs(var)
@test @inferred(ObsView(subset)) === subset
@test @inferred(ObsView(subset, 1:15)) === subset
@test subset[begin] == obsview(var, 1)
@test subset[end] == obsview(var, 15)
@test @inferred(subset[15]) == obsview(var, 15)
@test @inferred(subset[2:5]) == obsview(var, 2:5)
Expand Down Expand Up @@ -178,6 +179,7 @@ end
@test @inferred(A[1]) == obsview(var, 1)
@test @inferred(A[11]) == obsview(var, 11)
@test @inferred(A[15]) == obsview(var, 15)
@test A[begin] == A[1]
@test A[end] == A[15]
@test @inferred(getobs(A,1)) == getobs(var, 1)
@test @inferred(getobs(A,11)) == getobs(var, 11)
Expand Down

0 comments on commit 3a7d3e3

Please sign in to comment.