diff --git a/src/Dimensions/primitives.jl b/src/Dimensions/primitives.jl index df9ff765a..5fede080f 100644 --- a/src/Dimensions/primitives.jl +++ b/src/Dimensions/primitives.jl @@ -141,7 +141,7 @@ julia> A = DimArray(ones(2, 3, 2), (X, Y, Z)) 1.0 1.0 1.0 julia> dims(A, (X, Y)) -↓ X, → Y +(↓ X, → Y) ``` """ @@ -169,10 +169,10 @@ julia> using DimensionalData, .Dimensions julia> A = DimArray(ones(10, 10, 10), (X, Y, Z)); julia> commondims(A, X) -↓ X +(↓ X) julia> commondims(A, (X, Z)) -↓ X, → Z +(↓ X, → Z) julia> commondims(A, Ti) () @@ -285,10 +285,10 @@ julia> using DimensionalData, DimensionalData.Dimensions julia> A = DimArray(ones(10, 10, 10), (X, Y, Z)); julia> otherdims(A, X) -↓ Y, → Z +(↓ Y, → Z) julia> otherdims(A, (Y, Z)) -↓ X +(↓ X) ``` """ function otherdims end diff --git a/src/Dimensions/show.jl b/src/Dimensions/show.jl index 588d27fdf..7d485e6a9 100644 --- a/src/Dimensions/show.jl +++ b/src/Dimensions/show.jl @@ -18,7 +18,9 @@ function show_dims(io::IO, mime::MIME"text/plain", dims::DimTuple; ) ctx = IOContext(io, :compact => true) inset = get(io, :inset, "") + brackets = get(io, :dim_brackets, true) print(io, inset) + brackets && print(io, '(') if all(map(d -> !(parent(d) isa AbstractArray) || (parent(d) isa NoLookup), dims)) dc = colors[1] printstyled(io, dimsymbols(1), ' '; color=dc) @@ -30,6 +32,7 @@ function show_dims(io::IO, mime::MIME"text/plain", dims::DimTuple; printstyled(io, dimsymbols(n), ' '; color=dc) show(IOContext(ctx, :dimcolor => dc, :dimname_len => 0), mime, d) end + brackets && print(io, ')') return 0 else # Dims get a line each lines = 3 @@ -48,6 +51,7 @@ function show_dims(io::IO, mime::MIME"text/plain", dims::DimTuple; dim_ctx = IOContext(ctx, :dimcolor => dc, :dimname_len => maxname) show(dim_ctx, mime, d) end + brackets && print(io, ')') return lines end end diff --git a/src/array/array.jl b/src/array/array.jl index 5acfd5ea9..2ae57038e 100644 --- a/src/array/array.jl +++ b/src/array/array.jl @@ -742,13 +742,13 @@ placed at the end of `dims_new`. `others` contains other dimension pairs to be m julia> using DimensionalData julia> ds = (X(0:0.1:0.4), Y(10:10:100), Ti([0, 3, 4])) -↓ X 0.0:0.1:0.4, +(↓ X 0.0:0.1:0.4, → Y 10:10:100, -↗ Ti [0, 3, 4] +↗ Ti [0, 3, 4]) julia> mergedims(ds, (X, Y) => :space) -↓ Ti [0, 3, 4], -→ space MergedLookup{Tuple{Float64, Int64}} [(0.0, 10), (0.1, 10), …, (0.3, 100), (0.4, 100)] ↓ X, → Y +(↓ Ti [0, 3, 4], +→ space MergedLookup{Tuple{Float64, Int64}} [(0.0, 10), (0.1, 10), …, (0.3, 100), (0.4, 100)] (↓ X, → Y)) ``` """ function mergedims(x, dt1::Tuple, dts::Tuple...) diff --git a/src/array/show.jl b/src/array/show.jl index 6666a19d1..df03507e1 100644 --- a/src/array/show.jl +++ b/src/array/show.jl @@ -128,10 +128,11 @@ function print_dims_block(io, mime, dims; displaywidth, blockwidth, label="dims" printed = false new_blockwidth = blockwidth else - dim_lines = split(sprint(print_dims, mime, dims), '\n') + ctx = IOContext(io, :dim_brackets=>false) + dim_lines = split(sprint(print_dims, mime, dims; context=ctx), '\n') new_blockwidth = max(blockwidth, min(displaywidth - 2, maximum(textwidth, dim_lines))) - lines += print_block_top(io, label, blockwidth, new_blockwidth) - lines += print_dims(io, mime, dims; kw...) + lines += print_block_top(ctx, label, blockwidth, new_blockwidth) + lines += print_dims(ctx, mime, dims; kw...) println(io) lines += 1 printed = true diff --git a/src/dimindices.jl b/src/dimindices.jl index f643ad593..45095ed1e 100644 --- a/src/dimindices.jl +++ b/src/dimindices.jl @@ -95,9 +95,9 @@ julia> di = DimIndices((X(1:2:4), Y(1:2:4))) ↓ X 1:2:3, → Y 1:2:3 └─────────────────────────────────────────────┘ - ↓ → 1 3 - 1 ↓ X 1, → Y 1 ↓ X 1, → Y 3 - 3 ↓ X 3, → Y 1 ↓ X 3, → Y 3 + ↓ → 1 3 + 1 (↓ X 1, → Y 1) (↓ X 1, → Y 3) + 3 (↓ X 3, → Y 1) (↓ X 3, → Y 3) julia> A[di] # Index A with these indices ╭─────────────────────────╮ diff --git a/src/set.jl b/src/set.jl index bb8314055..14a024d49 100644 --- a/src/set.jl +++ b/src/set.jl @@ -90,7 +90,7 @@ julia> set(da, Z=DD.NoLookup(), custom=DD.Sampled()) │ 3×4 DimArray{Float64,2} │ ├─────────────────────────┴───────────────────────────────────────── dims ┐ ↓ custom Sampled{Float64} 10.0:10.0:30.0 ForwardOrdered Regular Points, - → Z + → Z └─────────────────────────────────────────────────────────────────────────┘ 10.0 0.0 0.0 0.0 0.0 20.0 0.0 0.0 0.0 0.0 diff --git a/src/stack/methods.jl b/src/stack/methods.jl index 844a3ee6c..a6577ae25 100644 --- a/src/stack/methods.jl +++ b/src/stack/methods.jl @@ -68,8 +68,8 @@ julia> size(slices) (4, 2) julia> map(dims, axes(slices)) -↓ Z Base.OneTo(4), -→ X Base.OneTo(2) +(↓ Z Base.OneTo(4), +→ X Base.OneTo(2)) julia> first(slices) ╭──────────────╮ diff --git a/src/stack/stack.jl b/src/stack/stack.jl index e5dd2763b..6877098fa 100644 --- a/src/stack/stack.jl +++ b/src/stack/stack.jl @@ -338,8 +338,8 @@ julia> using DimensionalData julia> A = [1.0 2.0 3.0; 4.0 5.0 6.0]; julia> dimz = (X([:a, :b]), Y(10.0:10.0:30.0)) -↓ X [:a, :b], -→ Y 10.0:10.0:30.0 +(↓ X [:a, :b], +→ Y 10.0:10.0:30.0) julia> da1 = DimArray(1A, dimz; name=:one); diff --git a/test/show.jl b/test/show.jl index 4e6b61e51..40a7aa2d0 100644 --- a/test/show.jl +++ b/test/show.jl @@ -91,7 +91,7 @@ end @test occursin("Transformed", sv) nds = (X(NoLookup(Base.OneTo(10))), Y(NoLookup(Base.OneTo(5)))) sv = sprint(show, MIME("text/plain"), nds) - @test sv == "↓ X, → Y" + @test sv == "(↓ X, → Y)" end @testset "arrays" begin