diff --git a/src/Dimensions/dimension.jl b/src/Dimensions/dimension.jl index 32b05c7ff..b315966bf 100644 --- a/src/Dimensions/dimension.jl +++ b/src/Dimensions/dimension.jl @@ -33,16 +33,16 @@ A = DimArray(zeros(3, 5, 12), (y, x, ti)) # output -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 +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] - 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...] + 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 @@ -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 ⋮ - 2021-10-01T00:00:00 0.0 - 2021-11-01T00:00:00 0.0 - 2021-12-01T00:00:00 0.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). @@ -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 diff --git a/src/Dimensions/primitives.jl b/src/Dimensions/primitives.jl index 6d5b994b9..0dcca7265 100644 --- a/src/Dimensions/primitives.jl +++ b/src/Dimensions/primitives.jl @@ -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} with dimensions: X, Y, Z[:, :, 1] - 1.0 1.0 1.0 - 1.0 1.0 1.0 -[and 1 more slices...] +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 @@ -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} 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...] +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...))