JuliaIO / HDF5.jl

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

Using `Type` and `Dataspace` in `create_dataset()` #1084

Closed duanhuaiyu closed 1 year ago

duanhuaiyu commented 1 year ago

According to the documentation of create_dataset(parent, path, datatype, dataspace; properties...), datatype can be either Datatype or Type, and dataspace can be either Dataspace or Dims. However, it throws an error if one uses datatype::Type with dataspace::Dataspace.

mkitti commented 1 year ago

Thank you. This is a bug. Here's a minimum working example. Pull requests are welcome. Let me see if I can tackle this in a few minutes.

julia> using HDF5

julia> h5open("test.h5", "w") do h5f
           create_dataset(h5f, "testds", UInt8, dataspace(16,16))
       end
ERROR: MethodError: no method matching create_dataset(::HDF5.File, ::String, ::Type{UInt8}, ::HDF5.Dataspace)

Closest candidates are:
  create_dataset(::Union{HDF5.File, HDF5.Group}, ::Union{Nothing, AbstractString}, ::HDF5.Datatype, ::HDF5.Dataspace; dcpl, dxpl, dapl, pv...)
   @ HDF5 ~/.julia/dev/HDF5/src/datasets.jl:44
  create_dataset(::Union{HDF5.File, HDF5.Group}, ::Union{Nothing, AbstractString}, ::Type, ::Tuple{Tuple{Vararg{Int64, N}} where N, Tuple{Vararg{Int64, N}} where N}; pv...)
   @ HDF5 ~/.julia/dev/HDF5/src/datasets.jl:94
  create_dataset(::Union{HDF5.File, HDF5.Group}, ::Union{Nothing, AbstractString}, ::Type, ::Tuple{Vararg{Int64, N}} where N; pv...)
   @ HDF5 ~/.julia/dev/HDF5/src/datasets.jl:107
  ...

Let me know if you would like to submit a test case.

mkitti commented 1 year ago

See #1086