-
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
Allow create_dataset to take a Type and Dataspace, Fix #1084 #1086
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using HDF5 | ||
using Test | ||
|
||
""" | ||
Test Set create_dataset | ||
|
||
Test the combination of arguments to create_dataset. | ||
""" | ||
|
||
@testset "create_dataset" begin | ||
mktemp() do fn, io | ||
h5open(fn, "w") do h5f | ||
h5g = create_group(h5f, "test_group") | ||
|
||
# Arguments | ||
# Test file and group | ||
parents = (h5f, h5g) | ||
# Test anonymous dattaset, String, and SubString | ||
names = (nothing, "test_dataset", @view("test_dataset"[1:4])) | ||
# Test primitive, HDF5.Datatype, non-primitive, non-primitive HDF5.Datatype | ||
types = (UInt8, datatype(UInt8), Complex{Float32}, datatype(Complex{Float32})) | ||
# Test Tuple, HDF5.Dataspace, two tuples (extendible), extendible HDF5.Dataspace | ||
spaces = ( | ||
(3, 4), | ||
dataspace((16, 16)), | ||
((4, 4), (8, 8)), | ||
dataspace((16, 16); max_dims=(32, 32)) | ||
) | ||
# TODO: test keywords | ||
|
||
# Create argument cross product | ||
p = Iterators.product(parents, names, types, spaces) | ||
|
||
for (parent, name, type, space) in p | ||
try | ||
# create a chunked dataset since contiguous datasets are not extendible | ||
ds = create_dataset(parent, name, type, space; chunk=(2, 2)) | ||
@test datatype(ds) == datatype(type) | ||
@test dataspace(ds) == dataspace(space) | ||
@test isvalid(ds) | ||
close(ds) | ||
if !isnothing(name) | ||
# if it is not an anonymous dataset, try to open it | ||
ds2 = open_dataset(parent, name) | ||
@test isvalid(ds2) | ||
close(ds2) | ||
delete_object(parent, name) | ||
end | ||
catch err | ||
throw(ArgumentError(""" | ||
Error occured with ( | ||
$parent :: $(typeof(parent)), | ||
$name :: $(typeof(name)), | ||
$type :: $(typeof(type)), | ||
$space :: $(typeof(space))) | ||
""")) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
should we document these additional methods? These were added for additional flexibility?
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 that we just implemented what wa already documented per #1084, but yes the documentation should reflect the new methods.
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 see the fix for adding the methods for
create_dataset
as per documentation, I was just curious on the newdataspace
methods.