From 103b9a5b545783326d74f53615d46f2140492b3c Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Tue, 10 Oct 2017 00:24:50 -0400 Subject: [PATCH] Adjust to reinterpret change (#192) --- src/JLD.jl | 10 ++++++---- src/JLD00.jl | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/JLD.jl b/src/JLD.jl index 5155202..db23517 100644 --- a/src/JLD.jl +++ b/src/JLD.jl @@ -592,15 +592,17 @@ _write(parent::Union{JldFile, JldGroup}, path::String, data::Array{Union{}}, function h5convert_array(f::JldFile, data::Array, dtype::JldDatatype, wsession::JldWriteSession) if dtype == JLD_REF_TYPE - refs = Vector{HDF5ReferenceObj}(length(data)) + # For type stability, return as Vector{UInt8} + refs = VERSION < v"0.7.0-DEV.2083" ? reinterpret(UInt8,Vector{HDF5ReferenceObj}(length(data))) : Vector{UInt8}(length(data)*sizeof(HDF5ReferenceObj)) + arefs = reinterpret(HDF5ReferenceObj, refs) for i = 1:length(data) if isassigned(data, i) - refs[i] = write_ref(f, data[i], wsession) + arefs[i] = write_ref(f, data[i], wsession) else - refs[i] = HDF5.HDF5ReferenceObj_NULL + arefs[i] = HDF5.HDF5ReferenceObj_NULL end end - reinterpret(UInt8, refs) # for type stability + refs else gen_h5convert(f, eltype(data)) h5convert_vals(f, data, dtype, wsession) diff --git a/src/JLD00.jl b/src/JLD00.jl index c0845a7..bd93cb9 100644 --- a/src/JLD00.jl +++ b/src/JLD00.jl @@ -525,13 +525,13 @@ end # Write "basic" types function write(parent::Union{JldFile, JldGroup}, name::String, - data::Union{T, Array{T}}, astype::String) where T<:Union{HDF5BitsKind, String} + data::Union{T, StridedArray{T}}, astype::String) where T<:Union{HDF5BitsKind, String} # Create the dataset dset, dtype = d_create(parent.plain, name, data) try # Write the attribute a_write(dset, name_type_attr, astype) - isa(data, Array) && isempty(data) && a_write(dset, "dims", [size(data)...]) + isa(data, StridedArray) && isempty(data) && a_write(dset, "dims", [size(data)...]) # Write the data HDF5.writearray(dset, dtype.id, data) finally @@ -602,7 +602,7 @@ function write(parent::Union{JldFile, JldGroup}, name::String, c::Complex) write(parent, name, reim, full_typename(typeof(c))) end function write(parent::Union{JldFile, JldGroup}, name::String, C::Array{T}) where T<:Complex - reim = reinterpret(realtype(T), C, ntuple(i->i==1 ? 2 : size(C,i-1), ndims(C)+1)) + reim = reinterpret(realtype(T), reshape(C, ntuple(i->i==1 ? 1 : size(C,i-1), ndims(C)+1))) write(parent, name, reim, full_typename(typeof(C))) end