Skip to content
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

Fix macro hygiene bug, remove unnecessary compat macros, and deprecated array constructor #354

Merged
merged 4 commits into from
Jan 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ end
provides(Sources, URI("http://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.0-patch1/src/hdf5-1.10.0-patch1.tar.gz"), hdf5)
provides(BuildProcess, Autotools(libtarget = "libhdf5.la"), hdf5)

@compat @BinDeps.install Dict(:libhdf5 => :libhdf5)
@BinDeps.install Dict(:libhdf5 => :libhdf5)
8 changes: 4 additions & 4 deletions src/blosc_filter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ const FILTER_BLOSC_VERSION = 2
const FILTER_BLOSC = 32001 # Filter ID registered with the HDF Group for Blosc
const blosc_name = "blosc"

const blosc_flags_ = Array(Cuint, 1)
const blosc_nelements_ = Array(Csize_t, 1)
const blosc_values = Array(Cuint, 8)
const blosc_chunkdims = Array(Hsize, 32)
const blosc_flags_ = Vector{Cuint}(1)
const blosc_nelements_ = Vector{Csize_t}(1)
const blosc_values = Vector{Cuint}(8)
const blosc_chunkdims = Vector{Hsize}(32)
function blosc_set_local(dcpl::Hid, htype::Hid, space::Hid)
blosc_nelements_[1] = 8
if ccall((:H5Pget_filter_by_id2,libhdf5), Herr,
Expand Down
2 changes: 1 addition & 1 deletion src/datafile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ read(f::Base.Callable, parent::DataFile, name::String...) =
# Read every variable in the file
function read(f::DataFile)
vars = names(f)
vals = Array(Any, length(vars))
vals = Vector{Any}(length(vars))
for i = 1:length(vars)
vals[i] = read(f, vars[i])
end
Expand Down
376 changes: 188 additions & 188 deletions src/plain.jl

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions test/extend_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ g = g_create(fid, "shoe")
d = d_create(g, "foo", datatype(Float64), ((10,20),(100,200)), "chunk", (1,1))
#println("d is size current $(map(int,HDF5.get_dims(d)[1])) max $(map(int,HDF5.get_dims(d)[2]))")
dims, max_dims = HDF5.get_dims(d)
ui64(n) = @compat UInt64(n)
@assert dims==(ui64(10),ui64(20))
ui64(n) = UInt64(n)
@assert dims == (ui64(10),ui64(20))
@assert max_dims == (ui64(100),ui64(200))
set_dims!(d, (100,150))
dims, max_dims = HDF5.get_dims(d)
@assert dims==(ui64(100),ui64(150))
@assert dims == (ui64(100),ui64(150))
@assert max_dims == (ui64(100),ui64(200))
d[1,1:5]=[1.1231,1.313,5.123,2.231,4.1231]
d[1,1:5] = [1.1231,1.313,5.123,2.231,4.1231]
set_dims!(d, (1,5))
@assert size(d) == (1,5)
#println("d is size current $(map(int,HDF5.get_dims(d)[1])) max $(map(int,HDF5.get_dims(d)[2]))")
Expand Down
4 changes: 2 additions & 2 deletions test/gc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ macro gcvalid(args...)
gc()
gc_enable(false)
end,
[:(@test HDF5.isvalid($x)) for x in args]...)
[:(@test HDF5.isvalid($(esc(x)))) for x in args]...)
end

macro closederror(x)
quote
try
$x
$(esc(x))
catch e
isa(e, ErrorException) || rethrow(e)
e.msg == "File or object has been closed" || error("Attempt to access closed object did not throw")
Expand Down
18 changes: 11 additions & 7 deletions test/plain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ fn = joinpath(tempdir(),"test.h5")
f = h5open(fn, "w")
# Write scalars
f["Float64"] = 3.2
f["Int16"] = @compat Int16(4)
f["Int16"] = Int16(4)
# compression of empty array (issue #246)
f["compressedempty", "shuffle", (), "compress", 4] = Array(Int64, 0)
f["bloscempty", "blosc", 4] = Array(Int64, 0)
f["compressedempty", "shuffle", (), "compress", 4] = Int64[]
f["bloscempty", "blosc", 4] = Int64[]
# Create arrays of different types
A = randn(3,5)
write(f, "Afloat64", convert(Matrix{Float64}, A))
Expand All @@ -36,16 +36,18 @@ let
HDF5.h5t_set_cset(dtype.id, HDF5.cset(typeof(salut)))
dspace = HDF5.dataspace(salut)
dset = HDF5.d_create(f, "salut-vlen", dtype, dspace)
HDF5.h5d_write(dset, dtype, HDF5.H5S_ALL, HDF5.H5S_ALL, HDF5.H5P_DEFAULT, [pointer(salut.data)])
HDF5.h5d_write(dset, dtype, HDF5.H5S_ALL, HDF5.H5S_ALL, HDF5.H5P_DEFAULT, [pointer(salut)])
end
# Arrays of strings
salut_split = ["Hi", "there"]
write(f, "salut_split", salut_split)
salut_2d = ["Hi" "there"; "Salut" "friend"]
write(f, "salut_2d", salut_2d)
# Arrays of strings as vlen
vlen = HDF5Vlen(salut_split)
d_write(f, "salut_vlen", vlen)
# Empty arrays
empty = Array(UInt32, 0)
empty = UInt32[]
write(f, "empty", empty)
# Empty strings
empty_string = ""
Expand Down Expand Up @@ -98,7 +100,7 @@ f["deleteme"] = 17.2
close(f)
# Test the h5read/write interface, with attributes
W = copy(reshape(1:120, 15, 8))
Wa = @compat Dict("a"=>1, "b"=>2)
Wa = Dict("a"=>1, "b"=>2)
h5write(fn, "newgroup/W", W)
h5writeattr(fn, "newgroup/W", Wa)

Expand Down Expand Up @@ -149,6 +151,8 @@ ucoder = read(fr, "ucode")
@assert ucode == ucoder
salut_splitr = read(fr, "salut_split")
@assert salut_splitr == salut_split
salut_2dr = read(fr, "salut_2d")
@assert salut_2d == salut_2dr
salut_vlenr = read(fr, "salut_vlen")
@assert salut_vlenr == salut_split
Rr = read(fr, "mygroup/CompressedA")
Expand Down Expand Up @@ -207,7 +211,7 @@ end
# Test reading multiple vars at once
z = read(fr, "Float64", "Int16")
@assert z == (3.2, 4)
@assert typeof(z) == @compat Tuple{Float64, Int16}
@assert typeof(z) == Tuple{Float64, Int16}
# Test function syntax
read(fr, "Float64") do x
@assert x == 3.2
Expand Down