Skip to content

Commit

Permalink
fix docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Apr 1, 2023
1 parent 925ee43 commit f2fb0e7
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 36 deletions.
58 changes: 30 additions & 28 deletions src/Dimensions/dimension.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ A = DimArray(zeros(3, 5, 12), (y, x, ti))
# output
3×5×12 DimArray{Float64,3}[90m with dimensions: [39m
[31mY[39m Categorical{Char} [36mChar['a', 'b', 'c'][39m ForwardOrdered,
[31mX[39m Sampled{Int64} [36m2:2:10[39m ForwardOrdered Regular Points,
[31mTi[39m Sampled{DateTime} [36mDateTime("2021-01-01T00:00:00"):Month(1):DateTime("2021-12-01T00:00:00")[39m ForwardOrdered Regular Points
3×5×12 DimArray{Float64,3} with dimensions:
Y Categorical{Char} Char['a', 'b', 'c'] ForwardOrdered,
X Sampled{Int64} 2:2:10 ForwardOrdered Regular Points,
Ti Sampled{DateTime} DateTime("2021-01-01T00:00:00"):Month(1):DateTime("2021-12-01T00:00:00") ForwardOrdered Regular Points
[:, :, 1]
[90m2[39m [90m4[39m [90m6[39m [90m8[39m [90m10[39m
[39m[90m'a'[39m [39m[39m0.0 [39m[39m0.0 [39m[39m0.0 [39m[39m0.0 [39m[39m0.0
[39m[90m'b'[39m [39m[39m0.0 [39m[39m0.0 [39m[39m0.0 [39m[39m0.0 [39m[39m0.0
[39m[90m'c'[39m [39m[39m0.0 [39m[39m0.0 [39m[39m0.0 [39m[39m0.0 [39m[39m0.0
[90m[and 11 more slices...][39m
2 4 6 8 10
'a' 0.0 0.0 0.0 0.0 0.0
'b' 0.0 0.0 0.0 0.0 0.0
'c' 0.0 0.0 0.0 0.0 0.0
[and 11 more slices...]
```
For simplicity, the same `Dimension` types are also used as wrappers
Expand All @@ -53,19 +53,20 @@ x = A[X(2), Y(3)]
# output
12-element DimArray{Float64,1} with dimensions: 
Ti Sampled{DateTime} DateTime("2021-01-01T00:00:00"):Month(1):DateTime("2021-12-01T00:00:00") ForwardOrdered Regular Points
and reference dimensions: 
Y Categorical{Char} Char['c'] ForwardOrdered,
X Sampled{Int64} 4:2:4 ForwardOrdered Regular Points
2021-01-01T00:00:00 0.0
2021-02-01T00:00:00 0.0
2021-03-01T00:00:00 0.0
2021-04-01T00:00:00 0.0
12-element DimArray{Float64,1} with dimensions:
Ti Sampled{DateTime} DateTime("2021-01-01T00:00:00"):Month(1):DateTime("2021-12-01T00:00:00") ForwardOrdered Regular Points
and reference dimensions:
Y Categorical{Char} Char['c'] ForwardOrdered,
X Sampled{Int64} 4:2:4 ForwardOrdered Regular Points
2021-01-01T00:00:00 0.0
2021-02-01T00:00:00 0.0
2021-03-01T00:00:00 0.0
2021-04-01T00:00:00 0.0
[90m2021-10-01T00:00:00[39m [39m0.0
[90m2021-11-01T00:00:00[39m [39m0.0
[90m2021-12-01T00:00:00[39m [39m0.0
2021-10-01T00:00:00 0.0
2021-11-01T00:00:00 0.0
2021-12-01T00:00:00 0.0
```
A `Dimension` can also wrap [`Selector`](@ref).
Expand All @@ -75,13 +76,14 @@ x = A[X(Between(3, 4)), Y(At('b'))]
# output
1×12 DimArray{Float64,2} with dimensions: 
X Sampled{Int64} 4:2:4 ForwardOrdered Regular Points,
Ti Sampled{DateTime} DateTime("2021-01-01T00:00:00"):Month(1):DateTime("2021-12-01T00:00:00") ForwardOrdered Regular Points
and reference dimensions: 
Y Categorical{Char} Char['b'] ForwardOrdered
2021-01-01T00:00:00 … 2021-12-01T00:00:00
4 0.0 0.0
1×12 DimArray{Float64,2} with dimensions:
X Sampled{Int64} 4:2:4 ForwardOrdered Regular Points,
Ti Sampled{DateTime} DateTime("2021-01-01T00:00:00"):Month(1):DateTime("2021-12-01T00:00:00") ForwardOrdered Regular Points
and reference dimensions:
Y Categorical{Char} Char['b'] ForwardOrdered
2021-01-01T00:00:00 … 2021-12-01T00:00:00
4 0.0 0.0
```
`Dimension` objects may have [`lookup`](@ref) and [`metadata`](@ref) fields
Expand Down
16 changes: 8 additions & 8 deletions src/Dimensions/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ any combination of either.
julia> using DimensionalData
julia> A = DimArray(ones(2, 3, 2), (X, Y, Z))
2×3×2 DimArray{Float64,3}[90m with dimensions: [39m[31mX[39m, [31mY[39m, [31mZ[39m[:, :, 1]
[39m[39m1.0 [39m[39m1.0 [39m[39m1.0
[39m[39m1.0 [39m[39m1.0 [39m[39m1.0
[90m[and 1 more slices...][39m
2×3×2 DimArray{Float64,3} with dimensions: X, Y, Z[:, :, 1]
1.0 1.0 1.0
1.0 1.0 1.0
[and 1 more slices...]
julia> dims(A, (X, Y))
X, Y
Expand Down Expand Up @@ -346,10 +346,10 @@ A = ones(X(2), Y(4), Z(2))
Dimensions.swapdims(A, (Dim{:a}, Dim{:b}, Dim{:c}))
# output
2×4×2 DimArray{Float64,3}[90m with dimensions: [39m[31mDim{[39m[33m:a[39m[31m}[39m, [31mDim{[39m[33m:b[39m[31m}[39m, [31mDim{[39m[33m:c[39m[31m}[39m[:, :, 1]
[39m[39m1.0 [39m[39m1.0 [39m[39m1.0 [39m[39m1.0
[39m[39m1.0 [39m[39m1.0 [39m[39m1.0 [39m[39m1.0
[90m[and 1 more slices...][39m
2×4×2 DimArray{Float64,3} with dimensions: Dim{:a}, Dim{:b}, Dim{:c}[:, :, 1]
1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0
[and 1 more slices...]
```
"""
@inline swapdims(x, d1, d2, ds...) = swapdims(x, (d1, d2, ds...))
Expand Down

0 comments on commit f2fb0e7

Please sign in to comment.