Skip to content

Commit

Permalink
Merge pull request #161 from singularitti/patch-2
Browse files Browse the repository at this point in the history
Update examples of `otherdims` & `commondims`
  • Loading branch information
rafaqz authored Aug 29, 2020
2 parents c1b0e5f + c06fb5e commit 5786c8d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ This is basically `dims(x, lookup)` where the order of the original is kept,
unlike [`dims`](@ref) where the lookup tuple determines the order
Also unlike `dims`,`commondims` always returns a `Tuple`, no matter the input.
```jldoctest
julia> using DimensionalData
julia> A = DimArray(ones(10, 10, 10), (X, Y, Z));
julia> commondims(A, X)
(X: Base.OneTo(10) (NoIndex),)
julia> commondims(A, (X, Z))
(X: Base.OneTo(10) (NoIndex), Z: Base.OneTo(10) (NoIndex))
julia> commondims(A, Ti)
()
```
"""
@inline commondims(A::AbstractArray, B::AbstractArray) = commondims(dims(A), dims(B))
@inline commondims(A::AbstractArray, lookup) = commondims(dims(A), lookup)
Expand Down Expand Up @@ -332,6 +346,14 @@ julia> using DimensionalData
julia> A = DimArray(ones(10, 10, 10), (X, Y, Z));
julia> otherdims(A, X)
(Y: Base.OneTo(10) (NoIndex), Z: Base.OneTo(10) (NoIndex))
julia> otherdims(A, (Y, Z))
(X: Base.OneTo(10) (NoIndex),)
julia> otherdims(A, Ti)
(X: Base.OneTo(10) (NoIndex), Y: Base.OneTo(10) (NoIndex), Z: Base.OneTo(10) (NoIndex))
```
"""
@inline otherdims(A::AbstractArray, lookup) = otherdims(dims(A), lookup)
Expand Down

0 comments on commit 5786c8d

Please sign in to comment.