Skip to content

Commit

Permalink
Merge pull request #354 from musm/compat
Browse files Browse the repository at this point in the history
Fix macro hygiene bug, remove unnecessary compat macros, and deprecated array constructor
  • Loading branch information
tkelman authored Jan 19, 2017
2 parents 110dc81 + 938be22 commit 20e8eb9
Show file tree
Hide file tree
Showing 7 changed files with 211 additions and 207 deletions.
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

0 comments on commit 20e8eb9

Please sign in to comment.