Skip to content

Commit

Permalink
Update fileio.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
musm committed Jun 19, 2021
1 parent f5c71b6 commit 8db51b0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/fileio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ function loadtodict!(d::Dict, g::Union{File,Group}, prefix::String="")
end

# load with just a filename returns a flat dictionary containing all the variables
function load(f::FileIO.File{FileIO.format"HDF5"}; kwargs...)
function fileio_load(f::FileIO.File{FileIO.format"HDF5"}; kwargs...)
h5open(FileIO.filename(f), "r"; kwargs...) do file
loadtodict!(Dict{String,Any}(), file)
end
end

# When called with explicitly requested variable names, return each one
function load(f::FileIO.File{FileIO.format"HDF5"}, varname::AbstractString; kwargs...)
function fileio_load(f::FileIO.File{FileIO.format"HDF5"}, varname::AbstractString; kwargs...)
h5open(FileIO.filename(f), "r"; kwargs...) do file
read(file, varname)
end
end

function load(f::FileIO.File{FileIO.format"HDF5"}, varnames::AbstractString...; kwargs...)
function fileio_load(f::FileIO.File{FileIO.format"HDF5"}, varnames::AbstractString...; kwargs...)
h5open(FileIO.filename(f), "r"; kwargs...) do file
map(var -> read(file, var), varnames)
end
Expand Down

0 comments on commit 8db51b0

Please sign in to comment.