From 208793014be821c22e61aff18e218e7b130ea942 Mon Sep 17 00:00:00 2001 From: JeremyBejanin Date: Mon, 2 Dec 2019 18:23:55 -0500 Subject: [PATCH 1/3] Avoid error with MATLAB classes that we can't handle --- src/MAT_HDF5.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/MAT_HDF5.jl b/src/MAT_HDF5.jl index 3001e70..1c35575 100644 --- a/src/MAT_HDF5.jl +++ b/src/MAT_HDF5.jl @@ -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 From 693ea0d3c7b8c9940bb3d6082ccc286736c5e2b2 Mon Sep 17 00:00:00 2001 From: JeremyBejanin Date: Mon, 2 Dec 2019 18:30:08 -0500 Subject: [PATCH 2/3] Add test for MATLAB classes that can't be read --- test/read.jl | 11 +++++++++++ test/v7.3/struct_table_datetime.mat | Bin 0 -> 34400 bytes 2 files changed, 11 insertions(+) create mode 100644 test/v7.3/struct_table_datetime.mat diff --git a/test/read.jl b/test/read.jl index db27d60..034df73 100644 --- a/test/read.jl +++ b/test/read.jl @@ -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 = matopen(m->read(m,"s"), joinpath(dirname(@__FILE__), "v7.3", objtestfile)) + @test "testTable" in keys(vars) + @test ismissing(vars["testTable"]) + @test "testDatetime" in keys(vars) + @test ismissing(vars["testDatetime"]) +end diff --git a/test/v7.3/struct_table_datetime.mat b/test/v7.3/struct_table_datetime.mat new file mode 100644 index 0000000000000000000000000000000000000000..9082308c5624adaf05a4ffd4e33dc9cabf4a8b38 GIT binary patch literal 34400 zcmeHQO>A4o5nhUM!Z>oGIBBZ(^a>+|S~xcCIF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SZq__3snaYSA0uaxf()SguWlS0yk(7>e zk8#d%=-3Wh17l3IP;2JFj)Xn4ZT9#0cDTIhdgGbtwD1J>Z$dY8rF>TLtP&)NX9l|i z?>gTjs3|$on#L?+gP2=Eag6gcHk3uwdtS)h>sfbR-}w2d8LzvZm%EhHjpAEU6+`=W zcHnPI6EZ#;{Y0VjxdEIy;Tzj`&|jN*Za}km1@r{$ao4ZgEPGtl71`ru%hz`8al}u; z5cV^_H~VtH*;Z#7@IlJ&G`sK=y)&oo$6a%~aQZjWKIYq2cA>W<^*sTmZx<>fb_j6o z!j!)Ev=a}iKd8+Z{C^eU1KRl3;E*

KRwi#D(O*>=&doP`2k74`3^@A_a_%3(F( z{6@6nLfAbxyU{HNj{e|GN6=m9DFJ6by5+sbx2=8MVVwW;Y2i5R>pA^lL(2aUkQ5i`=q8BPpMC^ajt2ttxxQJzS=(aHOKCtht_k> zUo-m-a=KA`>)Y2d;@0bjga5EE`~2&SfACM-b)wDkPgLELy}WFdWV`+e$FMm8?x8&V z56<&g2hOqo@Or{)gmX+A Date: Tue, 28 Apr 2020 12:25:37 -0400 Subject: [PATCH 3/3] fix reading variable names in mfiles with a subsystem entry --- src/MAT_HDF5.jl | 2 +- test/read.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MAT_HDF5.jl b/src/MAT_HDF5.jl index 1c35575..aa2c57f 100644 --- a/src/MAT_HDF5.jl +++ b/src/MAT_HDF5.jl @@ -275,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 diff --git a/test/read.jl b/test/read.jl index 034df73..e1f388b 100644 --- a/test/read.jl +++ b/test/read.jl @@ -217,7 +217,7 @@ end # 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 = matopen(m->read(m,"s"), joinpath(dirname(@__FILE__), "v7.3", objtestfile)) + vars = matread(joinpath(dirname(@__FILE__), "v7.3", objtestfile))["s"] @test "testTable" in keys(vars) @test ismissing(vars["testTable"]) @test "testDatetime" in keys(vars)