-
Notifications
You must be signed in to change notification settings - Fork 142
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
Add anonymous datasets #917
Conversation
src/HDF5.jl
Outdated
dapl::DatasetAccessProperties = DatasetAccessProperties(), | ||
pv... | ||
) | ||
path !== nothing && haskey(parent, path) && error("cannot create dataset: object \"", path, "\" already exists at ", name(parent)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth to test this as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify what you would like to test? I already test passing nothing
to the function.
The code for checking for an existing dataset already existed before this PR. Is there currently not a test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we already test the error for an existing dataset:
Lines 1362 to 1367 in 704d9e8
create_dataset(hfile, "dset1", 1) | |
create_dataset(hfile, "/group1/dset1", 1) | |
@test_throws ErrorException create_dataset(hfile, "dset1", 1) | |
@test_throws ErrorException create_dataset(hfile, "group1", 1) | |
@test_throws ErrorException create_dataset(g1, "dset1", 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind. When I read this, I thought you added this whole line, but that's not right heh
src/HDF5.jl
Outdated
pv = setproperties!(dcpl,dxpl,dapl; pv...) | ||
isempty(pv) || error("invalid keyword options") | ||
Dataset(API.h5d_create(parent, path, dtype, dspace, _link_properties(path), dcpl, dapl), file(parent), dxpl) | ||
if path isa Nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if path isa Nothing | |
if isnothing(path) |
would be more canonical
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://docs.julialang.org/en/v1/base/base/#Base.isnothing is only available with Julia 1.1. Have we broken compat with Julia 1.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
Interesting feature, didn't know this was possible. Apparently the python docs suggest this can be helpful for linking later. I still kind of wonder what kind of use case that would assist. |
Removed space within Union. Used `=== nothing` for consistency and Julia 1.0 compat. Co-authored-by: Mustafa M <mus-m@outlook.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use isnothing
.
src/HDF5.jl
Outdated
dtype::Datatype, | ||
dspace::Dataspace; | ||
dcpl::DatasetCreateProperties = DatasetCreateProperties(), | ||
dxpl::DatasetTransferProperties = DatasetTransferProperties(), | ||
dapl::DatasetAccessProperties = DatasetAccessProperties(), | ||
pv... | ||
) | ||
haskey(parent, path) && error("cannot create dataset: object \"", path, "\" already exists at ", name(parent)) | ||
path !== nothing && haskey(parent, path) && error("cannot create dataset: object \"", path, "\" already exists at ", name(parent)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path !== nothing && haskey(parent, path) && error("cannot create dataset: object \"", path, "\" already exists at ", name(parent)) | |
isnothing(path) || haskey(parent, path) && error("cannot create dataset: object \"", path, "\" already exists at ", name(parent)) |
src/HDF5.jl
Outdated
pv = setproperties!(dcpl,dxpl,dapl; pv...) | ||
isempty(pv) || error("invalid keyword options") | ||
Dataset(API.h5d_create(parent, path, dtype, dspace, _link_properties(path), dcpl, dapl), file(parent), dxpl) | ||
if path === nothing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if path === nothing | |
if isnothing(path) |
Co-authored-by: Mustafa M <mus-m@outlook.com>
In my application I'm using this to create a binary template for LabView to fill in with data. The anonymous datasets allows me to space out the real datasets at regular intervals so it is easy to fill in. This way LabView just knows that needs to know to write dataset at regular offsets and it can "create" a HDF5 file without using the HDF5 library. |
This adds
HDF5.API.h5d_create_anon
to allow for the creation of anonymous datasets.If
nothing
is passed as the path or name tocreate_dataset
or related functions, then an anonymous dataset is created. This mirrors what happens ifNone
is passed to h5py: https://docs.h5py.org/en/stable/high/group.html#h5py.Group.create_dataset