Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continue fix show #444

Merged
merged 5 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading