Skip to content

Commit

Permalink
Merge pull request #444 from JuliaDataCubes/continue_fix_show
Browse files Browse the repository at this point in the history
Continue fix show
  • Loading branch information
lazarusA authored Sep 22, 2024
2 parents 2c50bd1 + 773d627 commit f73d520
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
22 changes: 21 additions & 1 deletion docs/src/UserGuide/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,24 @@ and voilà
ds = Dataset(; (d_keys .=> yax_list)...)
````

now they are printed together, showing that is exactly the same axis structure for all variables.
now they are printed together, showing that is exactly the same axis structure for all variables.

## Create a `YAXArray` with unions containing `Strings`

````@example howdoi
test_x = stack(Vector{Union{Int,String}}[[1, "Test"], [2, "Test2"]])
yax_string = YAXArray(test_x)
````

or simply with an `Any` type

````@example howdoi
test_bool = ["Test1" 1 false; 2 "Test2" true; 1 2f0 1f2]
yax_bool = YAXArray(test_bool)
````

::: warning

Note that although their creation is allowed, it is not possible to save these types into Zarr or NetCDF.

:::
16 changes: 12 additions & 4 deletions src/Cubes/Cubes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -508,17 +508,25 @@ getCubeDes(::Type{T}) where {T} = string(T)

function DD.show_after(io::IO, mime, c::YAXArray)
blockwidth = get(io, :blockwidth, 0)
DD.print_block_separator(io, "file size", blockwidth, blockwidth)
println(io, " ")
println(io, " file size: ", formatbytes(cubesize(c)))
# ? sizeof : Check if the element type is a bitstype or a union of bitstypes
if (isconcretetype(eltype(c)) && isbitstype(eltype(c))) ||
(eltype(c) isa Union && all(isbitstype, Base.uniontypes(eltype(c))))

DD.print_block_separator(io, "file size", blockwidth, blockwidth)
println(io, "\n file size: ", formatbytes(cubesize(c)))
else # fallback
DD.print_block_separator(io, "memory size", blockwidth, blockwidth)
println(io, "\n summarysize: ", formatbytes(Base.summarysize(parent(c))))
end
DD.print_block_close(io, blockwidth)
# And if you want the array data to print:
# Uncomment to print array data if needed
# ndims(c) > 0 && println(io)
# DD.print_array(io, mime, c)
end




include("TransformedCubes.jl")
include("Slices.jl")
include("Rechunker.jl")
Expand Down

0 comments on commit f73d520

Please sign in to comment.