Skip to content

Commit e1246ae

Browse files
authored
Fix v0.16 HDF5 deprecations (#172)
* Fix v0.16 HDF5 deprecations
1 parent a82cb5a commit e1246ae

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1111
[compat]
1212
BufferedStreams = "0.4.1, 1"
1313
CodecZlib = "0.5, 0.6, 0.7"
14-
HDF5 = "0.14, 0.15, 0.16"
14+
HDF5 = "0.16"
1515
julia = "1.3"
1616

1717
[extras]

src/MAT_HDF5.jl

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,20 @@ function matopen(filename::AbstractString, rd::Bool, wr::Bool, cr::Bool, tr::Boo
8888
if !cr && !isfile(filename)
8989
error("File ", filename, " cannot be found")
9090
end
91-
pa = create_property(HDF5.H5P_FILE_ACCESS; fclose_degree = HDF5.H5F_CLOSE_STRONG)
91+
fapl = HDF5.FileAccessProperties()
92+
fapl.fclose_degree = :strong
9293
if cr && (tr || !isfile(filename))
9394
# We're truncating, so we don't have to check the format of an existing file
9495
# Set the user block to 512 bytes, to save room for the header
95-
p = create_property(HDF5.H5P_FILE_CREATE; userblock = 512)
96-
f = HDF5.h5f_create(filename, HDF5.H5F_ACC_TRUNC, p.id, pa.id)
96+
fcpl = HDF5.FileCreateProperties()
97+
fcpl.userblock = 512
98+
f = HDF5.API.h5f_create(filename, HDF5.API.H5F_ACC_TRUNC, fcpl, fapl)
9799
writeheader = true
98100
else
99-
f = HDF5.h5f_open(filename, wr ? HDF5.H5F_ACC_RDWR : HDF5.H5F_ACC_RDONLY, pa.id)
101+
f = HDF5.API.h5f_open(filename, wr ? HDF5.API.H5F_ACC_RDWR : HDF5.API.H5F_ACC_RDONLY, fapl)
100102
writeheader = false
101103
end
102-
close(pa)
104+
close(fapl)
103105
fid = MatlabHDF5File(HDF5.File(f, filename), true, writeheader, 0, compress)
104106
pathrefs = "/#refs#"
105107
if haskey(fid.plain, pathrefs)
@@ -175,8 +177,8 @@ function m_read(dset::HDF5.Dataset)
175177
# Check for a COMPOUND data set, and if so handle complex numbers specially
176178
dtype = datatype(dset)
177179
try
178-
class_id = HDF5.h5t_get_class(dtype.id)
179-
d = class_id == HDF5.H5T_COMPOUND ? read_complex(dtype, dset, T) : read(dset, T)
180+
class_id = HDF5.API.h5t_get_class(dtype.id)
181+
d = class_id == HDF5.API.H5T_COMPOUND ? read_complex(dtype, dset, T) : read(dset, T)
180182
length(d) == 1 ? d[1] : d
181183
finally
182184
close(dtype)
@@ -208,9 +210,9 @@ function m_read(g::HDF5.Group)
208210
T = str2type_matlab[mattype]
209211
try
210212
dtype = datatype(dset)
211-
class_id = HDF5.h5t_get_class(dtype.id)
213+
class_id = HDF5.API.h5t_get_class(dtype.id)
212214
try
213-
data = class_id == HDF5.H5T_COMPOUND ? read_complex(dtype, dset, T) : read(dset, T)
215+
data = class_id == HDF5.API.H5T_COMPOUND ? read_complex(dtype, dset, T) : read(dset, T)
214216
finally
215217
close(dtype)
216218
end
@@ -330,7 +332,7 @@ end
330332
function m_writearray(parent::HDF5Parent, name::String, adata::AbstractArray{T}, compress::Bool) where {T<:HDF5BitsOrBool}
331333
if compress
332334
dset, dtype = create_dataset(parent, name, adata;
333-
compress = 3, chunk = HDF5.heuristic_chunk(adata))
335+
deflate = 3, chunk = HDF5.heuristic_chunk(adata))
334336
else
335337
dset, dtype = create_dataset(parent, name, adata)
336338
end
@@ -350,7 +352,7 @@ function m_writearray(parent::HDF5Parent, name::String, adata::AbstractArray{Com
350352
stype = dataspace(adata)
351353
if compress
352354
dset = create_dataset(parent, name, dtype, stype;
353-
compress = 3, chunk = HDF5.heuristic_chunk(adata))
355+
deflate = 3, chunk = HDF5.heuristic_chunk(adata))
354356
else
355357
dset = create_dataset(parent, name, dtype, stype)
356358
end
@@ -599,19 +601,19 @@ end
599601

600602
## Utilities for handling complex numbers
601603
function build_datatype_complex(T::Type)
602-
memtype = create_datatype(HDF5.H5T_COMPOUND, 2*sizeof(T))
603-
HDF5.h5t_insert(memtype, "real", 0, HDF5.hdf5_type_id(T))
604-
HDF5.h5t_insert(memtype, "imag", sizeof(T), HDF5.hdf5_type_id(T))
604+
memtype = create_datatype(HDF5.API.H5T_COMPOUND, 2*sizeof(T))
605+
HDF5.API.h5t_insert(memtype, "real", 0, HDF5.hdf5_type_id(T))
606+
HDF5.API.h5t_insert(memtype, "imag", sizeof(T), HDF5.hdf5_type_id(T))
605607
return memtype
606608
end
607609

608610
function check_datatype_complex(dtype::HDF5.Datatype)
609-
n = HDF5.h5t_get_nmembers(dtype.id)
611+
n = HDF5.API.h5t_get_nmembers(dtype.id)
610612
if n != 2
611613
return false
612614
end
613-
if HDF5.h5t_get_member_name(dtype.id, 0) != "real" ||
614-
HDF5.h5t_get_member_name(dtype.id, 1) != "imag"
615+
if HDF5.API.h5t_get_member_name(dtype.id, 0) != "real" ||
616+
HDF5.API.h5t_get_member_name(dtype.id, 1) != "imag"
615617
return false
616618
end
617619
true

0 commit comments

Comments
 (0)