Skip to content

Commit 33123dc

Browse files
authored
Merge pull request #129 from jebej/patch-1
Avoid error with MATLAB classes that we can't handle
2 parents e5fe38d + 661a2ed commit 33123dc

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/MAT_HDF5.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ function m_read(dset::HDF5Dataset)
169169
end
170170
end
171171
return out
172+
elseif !haskey(str2type_matlab,mattype)
173+
@warn "MATLAB $mattype values are currently not supported"
174+
return missing
172175
end
173176

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

277280
"""
278281
exists(matfile_handle, varname) -> Bool

test/read.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,14 @@ let objtestfile = "figure.fig"
212212
@test vars["hgS_070000"]["handle"] == 1.0
213213
@test vars["hgS_070000"]["type"] == "figure"
214214
end
215+
216+
# test reading file containing Matlab table and datetime objects
217+
# since we don't support these objects, just make sure that there are no errors
218+
# reading the file and that the variables are there and replaced with `missing`
219+
let objtestfile = "struct_table_datetime.mat"
220+
vars = matread(joinpath(dirname(@__FILE__), "v7.3", objtestfile))["s"]
221+
@test "testTable" in keys(vars)
222+
@test ismissing(vars["testTable"])
223+
@test "testDatetime" in keys(vars)
224+
@test ismissing(vars["testDatetime"])
225+
end

test/v7.3/struct_table_datetime.mat

33.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)