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 to allow reading booleans from the file. #265

Closed
wants to merge 1 commit into from
Closed
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: 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