Skip to content

Commit

Permalink
Merge pull request JuliaIO#129 from jebej/patch-1
Browse files Browse the repository at this point in the history
Avoid error with MATLAB classes that we can't handle
  • Loading branch information
musm authored Sep 4, 2020
2 parents e5fe38d + 661a2ed commit 33123dc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/MAT_HDF5.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ function m_read(dset::HDF5Dataset)
end
end
return out
elseif !haskey(str2type_matlab,mattype)
@warn "MATLAB $mattype values are currently not supported"
return missing
end

# Regular arrays of values
Expand Down Expand Up @@ -272,7 +275,7 @@ Return a list of variables in an opened Matlab file.
See `matopen`.
"""
names(f::MatlabHDF5File) = filter!(x->x != "#refs#", names(f.plain))
names(f::MatlabHDF5File) = filter!(x -> x!="#refs#" && x!="#subsystem#", names(f.plain))

"""
exists(matfile_handle, varname) -> Bool
Expand Down
11 changes: 11 additions & 0 deletions test/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,14 @@ let objtestfile = "figure.fig"
@test vars["hgS_070000"]["handle"] == 1.0
@test vars["hgS_070000"]["type"] == "figure"
end

# test reading file containing Matlab table and datetime objects
# since we don't support these objects, just make sure that there are no errors
# reading the file and that the variables are there and replaced with `missing`
let objtestfile = "struct_table_datetime.mat"
vars = matread(joinpath(dirname(@__FILE__), "v7.3", objtestfile))["s"]
@test "testTable" in keys(vars)
@test ismissing(vars["testTable"])
@test "testDatetime" in keys(vars)
@test ismissing(vars["testDatetime"])
end
Binary file added test/v7.3/struct_table_datetime.mat
Binary file not shown.

0 comments on commit 33123dc

Please sign in to comment.