Skip to content

Commit

Permalink
Docstrings for the function copy_object (#1071)
Browse files Browse the repository at this point in the history
* Add docstring to copy_object

* Add an empty line for formatting

* Add interface/objects to documentation

* Add docstring for delete_object

* Add a short description for copy_object in the document

* Add delete_object to docs

---------

Co-authored-by: Mark Kittisopikul <markkitt@gmail.com>
  • Loading branch information
linwaytin and mkitti authored May 25, 2023
1 parent 3570bb8 commit 9bd0032
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ makedocs(;
"interface/dataset.md",
"interface/attributes.md",
"interface/properties.md",
"interface/filters.md"
"interface/filters.md",
"interface/objects.md",
],
"mpi.md",
"Low-level library bindings" => "api_bindings.md",
Expand Down
7 changes: 7 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,13 @@ b[1:10000] = collect(1:10000)

when dimensions are reduced, the truncated data is lost. A maximum dimension of -1 is often referred to as unlimited dimensions, though it is limited by the maximum size of an unsigned integer.

You can copy data from one file to another:

```julia
copy_object(source, data_name, target, name)
copy_object(source[data_name], target, name)
```

Finally, it's possible to delete objects:

```julia
Expand Down
10 changes: 10 additions & 0 deletions docs/src/interface/objects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Objects

```@meta
CurrentModule = HDF5
```

```@docs
copy_object
delete_object
```
11 changes: 11 additions & 0 deletions src/groups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ function Base.keys(x::Union{Group,File})
return children
end

"""
delete_object(parent::Union{File,Group}, path::AbstractString)
Delete the object at `parent[path]`.
# Examples
```julia
f = h5open("f.h5", "r+")
delete_object(f, "Group1")
```
"""
delete_object(
parent::Union{File,Group},
path::AbstractString,
Expand Down
22 changes: 22 additions & 0 deletions src/objects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ function gettype(parent, path::AbstractString)
end

# Copy objects
"""
copy_object(src_parent::Union{File,Group}, src_path::AbstractString, dst_parent::Union{File,Group}, dst_path::AbstractString)
Copy data from `src_parent[src_path]` to `dst_parent[dst_path]`.
# Examples
```julia
f = h5open("f.h5", "r")
g = h5open("g.h5", "cw")
copy_object(f, "Group1", g, "GroupA")
copy_object(f["Group1"], "data1", g, "DataSet/data_1")
```
"""
copy_object(
src_parent::Union{File,Group},
src_path::AbstractString,
Expand All @@ -58,6 +71,15 @@ copy_object(
API.H5P_DEFAULT,
_link_properties(dst_path)
)
"""
copy_object(src_obj::Object, dst_parent::Union{File,Group}, dst_path::AbstractString)
# Examples
```julia
copy_object(f["Group1"], g, "GroupA")
copy_object(f["Group1/data1"], g, "DataSet/data_1")
```
"""
copy_object(src_obj::Object, dst_parent::Union{File,Group}, dst_path::AbstractString) =
API.h5o_copy(
checkvalid(src_obj),
Expand Down

0 comments on commit 9bd0032

Please sign in to comment.