Skip to content

Commit

Permalink
more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
CarloLucibello committed Oct 23, 2022
1 parent dd7e856 commit 429062b
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/observation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,35 @@ difference between `numobs` and `Base.length`
`getobs` supports by default nested combinations of array, tuple,
named tuples, and dictionaries.
See also [`getobs`](@ref)
See also [`getobs`](@ref).
# Examples
```jldoctest
# named tuples
x = (a = [1, 2, 3], b = rand(6, 3))
numobs(x) == 3
# dictionaries
x = Dict(:a => [1, 2, 3], :b => rand(6, 3))
numobs(x) == 3
```
All internal containers must have the same number of observations:
```juliarepl
julia> x = (a = [1, 2, 3, 4], b = rand(6, 3));
julia> numobs(x)
ERROR: DimensionMismatch: All data containers must have the same number of observations.
Stacktrace:
[1] _check_numobs_error()
@ MLUtils ~/.julia/dev/MLUtils/src/observation.jl:163
[2] _check_numobs
@ ~/.julia/dev/MLUtils/src/observation.jl:130 [inlined]
[3] numobs(data::NamedTuple{(:a, :b), Tuple{Vector{Int64}, Matrix{Float64}}})
@ MLUtils ~/.julia/dev/MLUtils/src/observation.jl:177
[4] top-level scope
@ REPL[35]:1
```
"""
function numobs end

Expand Down

0 comments on commit 429062b

Please sign in to comment.