diff --git a/src/MAT_HDF5.jl b/src/MAT_HDF5.jl index 2ecd258..63cbf5c 100644 --- a/src/MAT_HDF5.jl +++ b/src/MAT_HDF5.jl @@ -229,6 +229,9 @@ function m_read(g::HDF5Group) data = str2eltype_matlab[mattype][] end return SparseMatrixCSC(convert(Int, HDF5.a_read(g, sparse_attr_matlab)), length(jc)-1, jc, ir, data) + elseif mattype == "function_handle" + @warn "MATLAB $mattype values are currently not supported" + return missing else error("Cannot read from a non-struct group, type was $mattype") end diff --git a/test/read.jl b/test/read.jl index e1f388b..866e631 100644 --- a/test/read.jl +++ b/test/read.jl @@ -213,9 +213,16 @@ let objtestfile = "figure.fig" @test vars["hgS_070000"]["type"] == "figure" end -# test reading file containing Matlab table and datetime objects +# test reading file containing Matlab function handle, 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 = "function_handles.mat" + vars = matread(joinpath(dirname(@__FILE__), "v7.3", objtestfile)) + @test "sin" in keys(vars) + @test ismissing(vars["sin"]) + @test "anonymous" in keys(vars) + @test ismissing(vars["anonymous"]) +end let objtestfile = "struct_table_datetime.mat" vars = matread(joinpath(dirname(@__FILE__), "v7.3", objtestfile))["s"] @test "testTable" in keys(vars) diff --git a/test/v7.3/function_handles.mat b/test/v7.3/function_handles.mat new file mode 100644 index 0000000..39e2b59 Binary files /dev/null and b/test/v7.3/function_handles.mat differ