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

It seems h5info is not implemented: is there an alternative? #815

Closed
PetrKryslUCSD opened this issue Feb 11, 2021 · 8 comments
Closed

It seems h5info is not implemented: is there an alternative? #815

PetrKryslUCSD opened this issue Feb 11, 2021 · 8 comments

Comments

@PetrKryslUCSD
Copy link

It seems h5info is not implemented: is there an alternative?
Similarly h5disp ...
I do appreciate this package: it is very useful!

@musm
Copy link
Member

musm commented Feb 12, 2021

h5info as in the matlab function https://www.mathworks.com/help/matlab/ref/h5info.html ?

@PetrKryslUCSD
Copy link
Author

Sorry: I made an incorrect assumption that h5info available in Matlab is a built-in function of HDF5.
So, is there something like this available in this package?

@musm
Copy link
Member

musm commented Feb 12, 2021

Does HDF5.show_tree satisfy your needs?

From test/plain.jl


# Make an interesting file tree
hfile = h5open(fn, "w")
# file level
hfile["version"] = 1.0
attributes(hfile)["creator"] = "HDF5.jl"
# group level
create_group(hfile, "inner")
attributes(hfile["inner"])["dirty"] = true
# dataset level
hfile["inner/data"] = collect(-5:5)
attributes(hfile["inner/data"])["mode"] = 1
# non-trivial committed datatype
# TODO: print more datatype information
tmeta = HDF5.Datatype(HDF5.h5t_create(HDF5.H5T_COMPOUND, sizeof(Int) + sizeof(Float64)))
HDF5.h5t_insert(tmeta, "scale", 0, HDF5.hdf5_type_id(Int))
HDF5.h5t_insert(tmeta, "bias", sizeof(Int), HDF5.hdf5_type_id(Float64))
tstr = datatype("fixed")
t = HDF5.Datatype(HDF5.h5t_create(HDF5.H5T_COMPOUND, sizeof(tmeta) + sizeof(tstr)))
HDF5.h5t_insert(t, "meta", 0, tmeta)
HDF5.h5t_insert(t, "type", sizeof(tmeta), tstr)
commit_datatype(hfile, "dtype", t)


# Example run

julia> HDF5.show_tree(hfile)
🗂️ HDF5.File: (read-write) C:\Users\Mus\AppData\Local\Temp\jl_TU1f7TtXWt
├─ 🏷️ creator
├─ 📄 dtype
├─ 📂 inner
│  ├─ 🏷️ dirty
│  └─ 🔢 data
│     └─ 🏷️ mode
└─ 🔢 version

@PetrKryslUCSD
Copy link
Author

I am like a child in a candy store! This is fantastic. This function should be well documented, it could well be a selling point that will seal the deal for someone who's interested in this package. At the moment I can't find it in the documentation.

@musm
Copy link
Member

musm commented Feb 12, 2021

Good point, we should definitely advertise this more and document it. At the same time this is the default method for show so it should show up transparently.

@jmert
Copy link
Contributor

jmert commented Feb 12, 2021

HDF5.show_tree is the implementation for the default 3-argument show method since v0.14. (#725)

@jmert
Copy link
Contributor

jmert commented Feb 12, 2021

That being said, a summary function like h5info that returns a Dict or NamedTuple data structure could still be useful and should be implementable.

@simonbyrne
Copy link
Collaborator

I think the default show addresses most of the relevant issues. If tweaks are required, please open another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants