JuliaIO / HDF5.jl

Save and load data in the HDF5 file format from Julia
https://juliaio.github.io/HDF5.jl
MIT License
380 stars 138 forks source link

Would it be possible to be able to save @enum values? #1149

Open AhmedSalih3d opened 3 months ago

AhmedSalih3d commented 3 months ago

Hello!

I have a use case in which @enums are awesome, integer identifiers for different variables to give the code more context / meaning.

I noticed that this does not work out of the box:

julia> @enum xxx::Int8 x = 1

julia> x
x::xxx = 1

julia> file["test"] = UInt8(x)
0x01

julia> file["test"] = x
ERROR: MethodError: no method matching hdf5_type_id(::Type{xxx}, ::Val{false})

Converting it to the correct type of course works as expected. I think it should be possible for the code to correctly parse a vector of enums and save it?

Kind regards

mkitti commented 2 weeks ago

We might be able to use HDF5 enum types for this: https://docs.hdfgroup.org/hdf5/v1_12/group___e_n_u_m.html