Skip to content

Commit

Permalink
Fix to allow reading booleans from the file.
Browse files Browse the repository at this point in the history
  • Loading branch information
pixel27 authored and JeffBezanson committed Jan 8, 2020
1 parent aed58b2 commit 395d47a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/jld_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,8 @@ function jldatatype(parent::JldFile, dtype::HDF5Datatype)
HDF5.h5t_equal(dtype.id, HDF5.H5T_NATIVE_UINT16) > 0 && return UInt16
HDF5.h5t_equal(dtype.id, HDF5.H5T_NATIVE_B8) > 0 && return Bool
error("unrecognized integer or float type")
elseif class_id == HDF5.H5T_BITFIELD
Bool
elseif class_id == HDF5.H5T_COMPOUND || class_id == HDF5.H5T_OPAQUE
addr = HDF5.objinfo(dtype).addr
haskey(parent.h5jltype, addr) && return parent.h5jltype[addr]
Expand Down
20 changes: 20 additions & 0 deletions test/jldtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ using HDF5, JLD
using Compat, LegacyStrings
using Compat.Test, Compat.LinearAlgebra
using Compat: @warn
using Random

@static if VERSION v"0.7.0-DEV.2329"
using Profile
Expand Down Expand Up @@ -983,3 +984,22 @@ mktempdir() do d
@test isempty(t.data) && eltype(t.data) == Pair{Any,Any}
rm(file)
end

# Issues #249 and #251
let fid = jldopen(fn, "w", mmaparrays = true)
write(fid, "a", true)
@test read(fid, "a") == true

write(fid, "b", false)
@test read(fid, "b") == false

write(fid, "c", Bool[true, true, false, false, true])
@test read(fid, "c") == Bool[true, true, false, false, true]

local t = Dict{String, Any}("a" => true, "b" => false, "c" => "xyz", "d" => 13)
write(fid, "d", t)
@test read(fid, "d") == t

close(fid)
rm(fn)
end

0 comments on commit 395d47a

Please sign in to comment.