Skip to content

Commit 1d1e1ab

Browse files
authored
Fix printing of YAXArrays as DD subtype. (#281)
* Fix printing of YAXArrays as DD subtype. * Fix printing of the dataset
1 parent ae03f7c commit 1d1e1ab

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/Cubes/Cubes.jl

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -474,14 +474,7 @@ cubesize(::YAXArray{T,0}) where {T} = sizeof(T)
474474
getCubeDes(::DD.Dimension) = "Cube axis"
475475
getCubeDes(::YAXArray) = "YAXArray"
476476
getCubeDes(::Type{T}) where {T} = string(T)
477-
Base.show(io::IO, c::YAXArray) = show_yax(io, c)
478-
Base.show(io::IO, mime::MIME{Symbol("text/plain")}, c::YAXArray) = show_yax(io,c)
479-
480-
function show_yax(io::IO, c)
481-
println(io, getCubeDes(c), " with the following dimensions")
482-
for a in caxes(c)
483-
println(io, a)
484-
end
477+
function DD.show_after(io::IO,mime, c::YAXArray)
485478
foreach(getattributes(c)) do p
486479
if p[1] in ("labels", "name", "units")
487480
println(io, p[1], ": ", p[2])

src/DatasetAPI/Datasets.jl

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,34 @@ end
9393
function Base.show(io::IO, ds::Dataset)
9494
sharedaxs = intersect([caxes(c) for (n,c) in ds.cubes]...)
9595
println(io, "YAXArray Dataset")
96+
9697
println(io, "Shared Axes: ")
97-
foreach(a -> println(io, " ", a), sharedaxs)
98+
show(io, MIME("text/plain"), tuple(sharedaxs...))
99+
println(io,"")
98100
println(io, "Variables: ")
99101
for (k,c) in ds.cubes
100-
println(io, k)
101102
specaxes = setdiff(caxes(c), sharedaxs)
102-
foreach(i-> println(io," └── ", i), specaxes)
103+
if !isempty(specaxes)
104+
println(io)
105+
println(io, k)
106+
specaxes = setdiff(caxes(c), sharedaxs)
107+
DD.Dimensions.print_dims(io, MIME("text/plain"), tuple(specaxes...))
108+
else
109+
print(io,k)
110+
print(io, ", ")
111+
end
112+
#for ax in specaxes
113+
# println(io," └── ")
114+
# DD.Dimensions.show_compact(io, MIME("text/plain"),ax)
115+
#end
103116
end
104117
#foreach(i -> print(io, i, " "), keys(ds.cubes))
118+
#show(io, ds.properties)
105119
if !isempty(ds.properties)
106120
println(io)
107121
print(io,"Properties: ")
108-
foreach(i -> print(io, i[1], " => ", i[2], " "), ds.properties)
122+
println(io, ds.properties)
123+
# foreach(i -> print(io, i[1], " => ", i[2], " "), ds.properties)
109124
end
110125
end
111126
function Base.propertynames(x::Dataset, private::Bool = false)

0 commit comments

Comments
 (0)