Skip to content

Commit

Permalink
make array type printing consistent with base (#854)
Browse files Browse the repository at this point in the history
* make array type printing consistent with base

`print_type` was missing a space inside the curly brackets. (My IDE
automatically removed trailing whitespace here, lmk if I should remove
those changes.)

* fix doctests
  • Loading branch information
simeonschaub authored Nov 11, 2024
1 parent b73b6ee commit 29a6b99
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 108 deletions.
18 changes: 9 additions & 9 deletions src/Dimensions/dimension.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ A = DimArray(zeros(3, 5, 12), (y, x, ti))
# output
╭────────────────────────────╮
│ 3×5×12 DimArray{Float64,3} │
├────────────────────────────┴─────────────────────────────────────────── dims ┐
╭────────────────────────────
│ 3×5×12 DimArray{Float64, 3} │
├─────────────────────────────┴────────────────────────────────────────── dims ┐
↓ Y Categorical{Char} ['a', 'b', 'c'] ForwardOrdered,
→ X Sampled{Int64} 2:2:10 ForwardOrdered Regular Points,
↗ Ti Sampled{Dates.DateTime} Dates.DateTime("2021-01-01T00:00:00"):Dates.Month(1):Dates.DateTime("2021-12-01T00:00:00") ForwardOrdered Regular Points
Expand All @@ -54,9 +54,9 @@ x = A[X(2), Y(3)]
# output
╭────────────────────────────────╮
│ 12-element DimArray{Float64,1} │
├────────────────────────────────┴─────────────────────────────────────── dims ┐
╭────────────────────────────────
│ 12-element DimArray{Float64, 1} │
├─────────────────────────────────┴────────────────────────────────────── dims ┐
↓ Ti Sampled{Dates.DateTime} Dates.DateTime("2021-01-01T00:00:00"):Dates.Month(1):Dates.DateTime("2021-12-01T00:00:00") ForwardOrdered Regular Points
└──────────────────────────────────────────────────────────────────────────────┘
2021-01-01T00:00:00 0.0
Expand All @@ -80,9 +80,9 @@ x = A[X(Between(3, 4)), Y(At('b'))]
# output
╭──────────────────────────╮
│ 1×12 DimArray{Float64,2} │
├──────────────────────────┴───────────────────────────────────────────── dims ┐
╭──────────────────────────
│ 1×12 DimArray{Float64, 2} │
├───────────────────────────┴──────────────────────────────────────────── dims ┐
↓ X Sampled{Int64} 4:2:4 ForwardOrdered Regular Points,
→ Ti Sampled{Dates.DateTime} Dates.DateTime("2021-01-01T00:00:00"):Dates.Month(1):Dates.DateTime("2021-12-01T00:00:00") ForwardOrdered Regular Points
└──────────────────────────────────────────────────────────────────────────────┘
Expand Down
16 changes: 8 additions & 8 deletions src/Dimensions/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ any combination of either.
julia> using DimensionalData
julia> A = DimArray(ones(2, 3, 2), (X, Y, Z))
╭───────────────────────────╮
│ 2×3×2 DimArray{Float64,3} │
├───────────────────── dims ┤
╭───────────────────────────
│ 2×3×2 DimArray{Float64, 3} │
├───────────────────── dims ┤
↓ X, → Y, ↗ Z
└───────────────────────────┘
└───────────────────────────
[:, :, 1]
1.0 1.0 1.0
1.0 1.0 1.0
Expand Down Expand Up @@ -364,11 +364,11 @@ A = ones(X(2), Y(4), Z(2))
Dimensions.swapdims(A, (Dim{:a}, Dim{:b}, Dim{:c}))
# output
╭───────────────────────────╮
│ 2×4×2 DimArray{Float64,3} │
├───────────────────── dims ┤
╭───────────────────────────
│ 2×4×2 DimArray{Float64, 3} │
├───────────────────── dims ┤
↓ a, → b, ↗ c
└───────────────────────────┘
└───────────────────────────
[:, :, 1]
1.0 1.0 1.0 1.0
1.0 1.0 1.0 1.0
Expand Down
6 changes: 3 additions & 3 deletions src/Lookups/lookup_arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,9 @@ y = Y(Sampled([1, 4, 7, 10]; span=Regular(3), sampling=Intervals(Start())))
A = ones(x, y)
# output
╭─────────────────────────╮
│ 5×4 DimArray{Float64,2} │
├─────────────────────────┴────────────────────────────────────────── dims ┐
╭─────────────────────────
│ 5×4 DimArray{Float64, 2} │
├──────────────────────────┴───────────────────────────────────────── dims ┐
↓ X Sampled{Int64} 100:-20:20 ReverseOrdered Regular Intervals{Start},
→ Y Sampled{Int64} [1, 4, 7, 10] ForwardOrdered Regular Intervals{Start}
└──────────────────────────────────────────────────────────────────────────┘
Expand Down
24 changes: 12 additions & 12 deletions src/Lookups/selector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,9 @@ A[X(Between(15, 25)), Y(Between(4, 6.5))]
# output
╭───────────────────────╮
│ 1×2 DimArray{Int64,2} │
├───────────────────────┴────────────────────────────── dims ┐
╭───────────────────────
│ 1×2 DimArray{Int64, 2} │
├────────────────────────┴───────────────────────────── dims ┐
↓ X Sampled{Int64} 20:10:20 ForwardOrdered Regular Points,
→ Y Sampled{Int64} 5:6 ForwardOrdered Regular Points
└────────────────────────────────────────────────────────────┘
Expand Down Expand Up @@ -853,9 +853,9 @@ A = DimArray([1 2 3; 4 5 6], (X(10:10:20), Y(5:7)))
A[X(Touches(15, 25)), Y(Touches(4, 6.5))]
# output
╭───────────────────────╮
│ 1×2 DimArray{Int64,2} │
├───────────────────────┴────────────────────────────── dims ┐
╭───────────────────────
│ 1×2 DimArray{Int64, 2} │
├────────────────────────┴───────────────────────────── dims ┐
↓ X Sampled{Int64} 20:10:20 ForwardOrdered Regular Points,
→ Y Sampled{Int64} 5:6 ForwardOrdered Regular Points
└────────────────────────────────────────────────────────────┘
Expand Down Expand Up @@ -1029,9 +1029,9 @@ A[X(Where(x -> x > 15)), Y(Where(x -> x in (19, 21)))]
# output
╭───────────────────────╮
│ 1×2 DimArray{Int64,2} │
├───────────────────────┴─────────────────────────────── dims ┐
╭───────────────────────
│ 1×2 DimArray{Int64, 2} │
├────────────────────────┴────────────────────────────── dims ┐
↓ X Sampled{Int64} [20] ForwardOrdered Irregular Points,
→ Y Sampled{Int64} [19, 21] ForwardOrdered Irregular Points
└─────────────────────────────────────────────────────────────┘
Expand Down Expand Up @@ -1071,9 +1071,9 @@ A[X=All(At(10.0), At(50.0)), Ti=All(1u"s"..10u"s", 90u"s"..100u"s")]
# output
╭───────────────────────╮
│ 2×4 DimArray{Int64,2} │
├───────────────────────┴──────────────────────────────────────────────── dims ┐
╭───────────────────────
│ 2×4 DimArray{Int64, 2} │
├────────────────────────┴─────────────────────────────────────────────── dims ┐
↓ X Sampled{Float64} [10.0, 50.0] ForwardOrdered Irregular Points,
→ Ti Sampled{Unitful.Quantity{Int64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}} [1 s, 6 s, 91 s, 96 s] ForwardOrdered Irregular Points
└──────────────────────────────────────────────────────────────────────────────┘
Expand Down
62 changes: 31 additions & 31 deletions src/array/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -396,18 +396,18 @@ julia> x = X(10:10:100);
julia> A = DimArray(rand(12,10), (ti, x), name="example");
julia> A[X(Near([12, 35])), Ti(At(DateTime(2001,5)))]
╭───────────────────────────────────────╮
│ 2-element DimArray{Float64,1} example │
├───────────────────────────────────────┴─────────────── dims ┐
╭───────────────────────────────────────
│ 2-element DimArray{Float64, 1} example │
├────────────────────────────────────────┴────────────── dims ┐
↓ X Sampled{Int64} [10, 40] ForwardOrdered Irregular Points
└─────────────────────────────────────────────────────────────┘
10 0.253849
40 0.637077
julia> A[Near(DateTime(2001, 5, 4)), Between(20, 50)]
╭───────────────────────────────────────╮
│ 4-element DimArray{Float64,1} example │
├───────────────────────────────────────┴───────────── dims ┐
╭───────────────────────────────────────
│ 4-element DimArray{Float64, 1} example │
├────────────────────────────────────────┴──────────── dims ┐
↓ X Sampled{Int64} 20:10:50 ForwardOrdered Regular Points
└───────────────────────────────────────────────────────────┘
20 0.774092
Expand Down Expand Up @@ -522,11 +522,11 @@ Keywords are the same as for [`DimArray`](@ref).
julia> using DimensionalData, Random; Random.seed!(123);
julia> fill(true, X(2), Y(4))
╭──────────────────────╮
│ 2×4 DimArray{Bool,2} │
├──────────────── dims ┤
╭──────────────────────
│ 2×4 DimArray{Bool, 2} │
├──────────────── dims ┤
↓ X, → Y
└──────────────────────┘
└──────────────────────
1 1 1 1
1 1 1 1
```
Expand Down Expand Up @@ -555,18 +555,18 @@ Keywords are the same as for [`DimArray`](@ref).
julia> using DimensionalData
julia> rand(Bool, X(2), Y(4))
╭──────────────────────╮
│ 2×4 DimArray{Bool,2} │
├──────────────── dims ┤
╭──────────────────────
│ 2×4 DimArray{Bool, 2} │
├──────────────── dims ┤
↓ X, → Y
└──────────────────────┘
└──────────────────────
0 0 0 0
1 0 0 1
julia> rand(X([:a, :b, :c]), Y(100.0:50:200.0))
╭─────────────────────────╮
│ 3×3 DimArray{Float64,2} │
├─────────────────────────┴───────────────────────────────────── dims ┐
╭─────────────────────────
│ 3×3 DimArray{Float64, 2} │
├──────────────────────────┴──────────────────────────────────── dims ┐
↓ X Categorical{Symbol} [:a, :b, :c] ForwardOrdered,
→ Y Sampled{Float64} 100.0:50.0:200.0 ForwardOrdered Regular Points
└─────────────────────────────────────────────────────────────────────┘
Expand Down Expand Up @@ -598,18 +598,18 @@ Keywords are the same as for [`DimArray`](@ref).
julia> using DimensionalData
julia> zeros(Bool, X(2), Y(4))
╭──────────────────────╮
│ 2×4 DimArray{Bool,2} │
├──────────────── dims ┤
╭──────────────────────
│ 2×4 DimArray{Bool, 2} │
├──────────────── dims ┤
↓ X, → Y
└──────────────────────┘
└──────────────────────
0 0 0 0
0 0 0 0
julia> zeros(X([:a, :b, :c]), Y(100.0:50:200.0))
╭─────────────────────────╮
│ 3×3 DimArray{Float64,2} │
├─────────────────────────┴───────────────────────────────────── dims ┐
╭─────────────────────────
│ 3×3 DimArray{Float64, 2} │
├──────────────────────────┴──────────────────────────────────── dims ┐
↓ X Categorical{Symbol} [:a, :b, :c] ForwardOrdered,
→ Y Sampled{Float64} 100.0:50.0:200.0 ForwardOrdered Regular Points
└─────────────────────────────────────────────────────────────────────┘
Expand Down Expand Up @@ -642,18 +642,18 @@ Keywords are the same as for [`DimArray`](@ref).
julia> using DimensionalData
julia> ones(Bool, X(2), Y(4))
╭──────────────────────╮
│ 2×4 DimArray{Bool,2} │
├──────────────── dims ┤
╭──────────────────────
│ 2×4 DimArray{Bool, 2} │
├──────────────── dims ┤
↓ X, → Y
└──────────────────────┘
└──────────────────────
1 1 1 1
1 1 1 1
julia> ones(X([:a, :b, :c]), Y(100.0:50:200.0))
╭─────────────────────────╮
│ 3×3 DimArray{Float64,2} │
├─────────────────────────┴───────────────────────────────────── dims ┐
╭─────────────────────────
│ 3×3 DimArray{Float64, 2} │
├──────────────────────────┴──────────────────────────────────── dims ┐
↓ X Categorical{Symbol} [:a, :b, :c] ForwardOrdered,
→ Y Sampled{Float64} 100.0:50.0:200.0 ForwardOrdered Regular Points
└─────────────────────────────────────────────────────────────────────┘
Expand Down
Loading

0 comments on commit 29a6b99

Please sign in to comment.