Skip to content

Commit 99fa8d0

Browse files
committed
Rename public functions
1 parent 229d335 commit 99fa8d0

File tree

2 files changed

+51
-21
lines changed

2 files changed

+51
-21
lines changed

src/HDF5.jl

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ export
1919
# Attribute, File, Group, Dataset, Datatype, Opaque
2020
# Dataspace, Object, Properties, VLen, ChunkStorage, Reference
2121
# functions
22-
a_create, a_delete, a_open, a_read, a_write, attrs,
23-
d_create, d_create_external, d_open, d_read, d_write,
24-
dataspace, datatype, exists, file, filename,
25-
g_create, g_open, get_access_properties, get_create_properties,
22+
create_attribute, delete_attribute, read_attribute, open_attribute, write_attribute, attributes,
23+
create_dataset, create_external_dataset, open_dataset, read_dataset, write_dataset,
24+
dataspace, datatype, file, filename,
25+
create_group, open_group,
26+
create_datatype, commit_datatype,
27+
copy_object, delete_object, open_object, create_property,
28+
get_access_properties, get_create_properties,
2629
get_chunk, get_datasets,
2730
h5open, h5read, h5rewrite, h5writeattr, h5readattr, h5write,
2831
iscontiguous, ishdf5, ismmappable, name,
29-
o_copy, o_delete, o_open, p_create,
30-
readmmap, @read, @write, root, set_dims!, t_create, t_commit
32+
readmmap, @read, @write, root, set_dims!
3133

3234
const depsfile = joinpath(dirname(@__DIR__), "deps", "deps.jl")
3335
if isfile(depsfile)
@@ -635,7 +637,7 @@ flush(f::Union{Object,Attribute,Datatype,File}, scope = H5F_SCOPE_GLOBAL) = h5f_
635637
g_open(parent::Union{File,Group}, name::String, apl::Properties=DEFAULT_PROPERTIES) = Group(h5g_open(checkvalid(parent).id, name, apl.id), file(parent))
636638
d_open(parent::Union{File,Group}, name::String, apl::Properties=DEFAULT_PROPERTIES, xpl::Properties=DEFAULT_PROPERTIES) = Dataset(h5d_open(checkvalid(parent).id, name, apl.id), file(parent), xpl)
637639
t_open(parent::Union{File,Group}, name::String, apl::Properties=DEFAULT_PROPERTIES) = Datatype(h5t_open(checkvalid(parent).id, name, apl.id), file(parent))
638-
a_open(parent::Union{File,Object}, name::String) = Attribute(h5a_open(checkvalid(parent).id, name, H5P_DEFAULT), file(parent))
640+
open_attribute(parent::Union{File,Object}, name::String) = Attribute(h5a_open(checkvalid(parent).id, name, H5P_DEFAULT), file(parent))
639641
# Object (group, named datatype, or dataset) open
640642
function h5object(obj_id::hid_t, parent)
641643
obj_type = h5i_get_type(obj_id)
@@ -656,8 +658,8 @@ root(h5file::File) = g_open(h5file, "/")
656658
root(obj::Union{Group,Dataset}) = g_open(file(obj), "/")
657659
# getindex syntax: obj2 = obj1[path]
658660
#getindex(parent::Union{HDF5File, HDF5Group}, path::String) = o_open(parent, path)
659-
getindex(dset::Dataset, name::String) = a_open(dset, name)
660-
getindex(x::Attributes, name::String) = a_open(x.parent, name)
661+
getindex(dset::Dataset, name::String) = open_attribute(dset, name)
662+
getindex(x::Attributes, name::String) = open_attribute(x.parent, name)
661663

662664
function getindex(parent::Union{File,Group}, path::String; pv...)
663665
objtype = gettype(parent, path)
@@ -740,7 +742,7 @@ function t_commit(parent::Union{File,Group}, path::String, dtype::Datatype, lcpl
740742
end
741743
t_commit(parent::Union{File,Group}, path::String, dtype::Datatype) = t_commit(parent, path, dtype, p_create(H5P_LINK_CREATE))
742744

743-
a_create(parent::Union{File,Object}, name::String, dtype::Datatype, dspace::Dataspace) = Attribute(h5a_create(checkvalid(parent).id, name, dtype.id, dspace.id), file(parent))
745+
create_attribute(parent::Union{File,Object}, name::String, dtype::Datatype, dspace::Dataspace) = Attribute(h5a_create(checkvalid(parent).id, name, dtype.id, dspace.id), file(parent))
744746

745747
function _prop_get(p::Properties, name::Symbol)
746748
class = p.class
@@ -859,7 +861,7 @@ function p_create(class; pv...)
859861
end
860862

861863
# Delete objects
862-
a_delete(parent::Union{File,Object}, path::String) = h5a_delete(checkvalid(parent).id, path)
864+
delete_attribute(parent::Union{File,Object}, path::String) = h5a_delete(checkvalid(parent).id, path)
863865
o_delete(parent::Union{File,Group}, path::String, lapl::Properties) = h5l_delete(checkvalid(parent).id, path, lapl.id)
864866
o_delete(parent::Union{File,Group}, path::String) = h5l_delete(checkvalid(parent).id, path, H5P_DEFAULT)
865867
o_delete(obj::Object) = o_delete(parent(obj), ascii(split(name(obj),"/")[end]))
@@ -870,8 +872,8 @@ o_copy(src_obj::Object, dst_parent::Union{File,Group}, dst_path::String) = h5o_c
870872

871873
# Assign syntax: obj[path] = value
872874
# Creates a dataset unless obj is a dataset, in which case it creates an attribute
873-
setindex!(dset::Dataset, val, name::String) = a_write(dset, name, val)
874-
setindex!(x::Attributes, val, name::String) = a_write(x.parent, name, val)
875+
setindex!(dset::Dataset, val, name::String) = write_attribute(dset, name, val)
876+
setindex!(x::Attributes, val, name::String) = write_attribute(x.parent, name, val)
875877
# Getting and setting properties: p[:chunk] = dims, p[:compress] = 6
876878
getindex(p::Properties, name::Symbol) = _prop_get(checkvalid(p), name)
877879
function setindex!(p::Properties, val, name::Symbol)
@@ -1039,7 +1041,7 @@ dataspace(dset::Dataset) = Dataspace(h5d_get_space(checkvalid(dset).id))
10391041
dataspace(attr::Attribute) = Dataspace(h5a_get_space(checkvalid(attr).id))
10401042

10411043
# Create a dataspace from in-memory types
1042-
dataspace(x::Union{T, Complex{T}}) where {T<:ScalarType} = Dataspace(h5s_create(H5S_SCALAR))
1044+
dataspace(x::Union{T,Complex{T}}) where {T<:ScalarType} = Dataspace(h5s_create(H5S_SCALAR))
10431045

10441046
function _dataspace(sz::Dims{N}, max_dims::Union{Dims{N}, Tuple{}}=()) where N
10451047
dims = Vector{hsize_t}(undef,length(sz))
@@ -1105,7 +1107,7 @@ flush(ds::Dataset) = h5d_flush(checkvalid(ds).id)
11051107
# Generic read functions
11061108
for (fsym, osym, ptype) in
11071109
((:d_read, :d_open, Union{File,Group}),
1108-
(:a_read, :a_open, Union{File,Group,Dataset,Datatype}))
1110+
(:read_attribute, :open_attribute, Union{File,Group,Dataset,Datatype}))
11091111
@eval begin
11101112
function ($fsym)(parent::$ptype, name::String)
11111113
local ret
@@ -1292,7 +1294,7 @@ do_reclaim(::Type{T}) where {T} = false
12921294
do_reclaim(::Type{NamedTuple{T,U}}) where {U,T} = any(i -> do_reclaim(fieldtype(U,i)), 1:fieldcount(U))
12931295
do_reclaim(::Type{T}) where T <: Union{Cstring,VariableArray} = true
12941296

1295-
read(attr::Attributes, name::String) = a_read(attr.parent, name)
1297+
read(attr::Attributes, name::String) = read_attribute(attr.parent, name)
12961298

12971299
# Reading with mmap
12981300
function iscontiguous(obj::Dataset)
@@ -1390,7 +1392,7 @@ end
13901392
# The return syntax is: dset, dtype = d_create(parent, name, data; properties...)
13911393
for (privatesym, fsym, ptype) in
13921394
((:_d_create, :d_create, Union{File,Group}),
1393-
(:_a_create, :a_create, Union{File, Group, Dataset, Datatype}))
1395+
(:_a_create, :create_attribute, Union{File, Group, Dataset, Datatype}))
13941396
@eval begin
13951397
# Generic create (hidden)
13961398
function ($privatesym)(parent::$ptype, name::String, data; pv...)
@@ -1415,7 +1417,7 @@ end
14151417
# Create and write, closing the objects upon exit
14161418
for (privatesym, fsym, ptype, crsym) in
14171419
((:_d_write, :d_write, Union{File,Group}, :d_create),
1418-
(:_a_write, :a_write, Union{File,Object,Datatype}, :a_create))
1420+
(:_a_write, :write_attribute, Union{File,Object,Datatype}, :create_attribute))
14191421
@eval begin
14201422
# Generic write (hidden)
14211423
function ($privatesym)(parent::$ptype, name::String, data; pv...)
@@ -1457,9 +1459,9 @@ end
14571459
# For plain files and groups, let "write(obj, name, val; properties...)" mean "d_write"
14581460
write(parent::Union{File,Group}, name::String, data::Union{T,AbstractArray{T}}; pv...) where {T<:Union{ScalarType,String,Complex{<:ScalarType}}} =
14591461
d_write(parent, name, data; pv...)
1460-
# For datasets, "write(dset, name, val; properties...)" means "a_write"
1462+
# For datasets, "write(dset, name, val; properties...)" means "write_attribute"
14611463
write(parent::Dataset, name::String, data::Union{T, AbstractArray{T}}; pv...) where {T<:ScalarType,String} =
1462-
a_write(parent, name, data; pv...)
1464+
write_attribute(parent, name, data; pv...)
14631465

14641466

14651467
# Indexing

src/deprecated.jl

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function __d_create(parent::Union{File, Group}, path::String, dtype::Datatype,
7575
d_create(parent, path, dtype, dspace, lcpl, dcpl, dapl, dxpl)
7676
end
7777
# a_create doesn't take property lists, so just bind the helper name directly
78-
const __a_create = a_create
78+
const __a_create = create_attribute
7979

8080
for (fsym, ptype) in ((:d_create, Union{File, Group}),
8181
(:a_create, Union{File, Object}),
@@ -224,3 +224,31 @@ end
224224
### Changed in PR#694
225225
@deprecate has(parent::Union{File,Group,Dataset}, path::String) Base.haskey(parent, path)
226226
@deprecate exists(parent::Union{File,Group,Dataset,Datatype,Attributes}, path::String) Base.haskey(parent, path) false
227+
228+
### Changed in PR#696
229+
# - rename exported bindings
230+
@deprecate a_create create_attribute
231+
@deprecate a_delete delete_attribute
232+
@deprecate a_open open_attribute
233+
@deprecate a_read read_attribute
234+
@deprecate a_write write_attribute
235+
236+
@deprecate attrs attributes
237+
238+
@deprecate d_create create_dataset
239+
@deprecate d_create_external create_external_dataset
240+
@deprecate d_open open_dataset
241+
@deprecate d_read read_dataset
242+
@deprecate d_write write_dataset
243+
244+
@deprecate g_create create_group
245+
@deprecate g_open open_group
246+
247+
@deprecate o_copy copy_object
248+
@deprecate o_delete delete_object
249+
@deprecate o_open open_object
250+
251+
@deprecate p_create create_property
252+
253+
@deprecate t_create create_datatype
254+
@deprecate t_commit commit_datatype

0 commit comments

Comments
 (0)