From 4d33c78bae997e148ca4690cac01b690dcbf5538 Mon Sep 17 00:00:00 2001 From: Jeroen van der Meer Date: Mon, 20 May 2024 03:42:34 +0200 Subject: [PATCH] Attempt reading old-style Matlab class in v7.3 as struct (#198) * Attempt reading old classes in v7.3 as struct * Add test file --- src/MAT_HDF5.jl | 2 +- test/read.jl | 7 +++++++ test/v7.3/old_class.mat | Bin 0 -> 4504 bytes 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/v7.3/old_class.mat diff --git a/src/MAT_HDF5.jl b/src/MAT_HDF5.jl index c31ac82..00d2f54 100644 --- a/src/MAT_HDF5.jl +++ b/src/MAT_HDF5.jl @@ -229,7 +229,7 @@ function m_read(g::HDF5.Group) @warn "MATLAB $mattype values are currently not supported" return missing else - error("Cannot read from a non-struct group, type was $mattype") + @warn "Unknown non-struct group of type $mattype detected; attempting to read as struct" end end if haskey(g, "MATLAB_fields") diff --git a/test/read.jl b/test/read.jl index 67e62ab..4d8c9d4 100644 --- a/test/read.jl +++ b/test/read.jl @@ -230,3 +230,10 @@ let objtestfile = "struct_table_datetime.mat" @test "testDatetime" in keys(vars) @test ismissing(vars["testDatetime"]) end + +# test reading of old-style Matlab object in v7.3 format +let objtestfile = "old_class.mat" + vars = matread(joinpath(dirname(@__FILE__), "v7.3", objtestfile)) + @test "tc_old" in keys(vars) + @test "foo" in keys(vars["tc_old"]) +end diff --git a/test/v7.3/old_class.mat b/test/v7.3/old_class.mat new file mode 100644 index 0000000000000000000000000000000000000000..6949f6c3b6f987a5136727840659db76637c08f6 GIT binary patch literal 4504 zcmeHKL2nX46n;ZnyCPUxV`4l_(n}8&0YMv1AcbrbX*WuuH(Yjy6tl1dwg>+~y?ONL z(VyVKAK=gM=-GJirZYS5wXlI;=|P+B5ca*DdGF2Jx8Hs<)2z0hRiE-F*+;xtZ9VAr zJh96y&knl&s9)w*?d8GYpT2;WTS1t9xukfh}PhSyd zRE)rB`<@H1JrdpVwnCI{6*9P>Wb%uc#BT=i`|Gw2^bzAN!tXGx4P*Rb!LFHz;ul#K zPLbEB99`cJRl==F153&mhe!Ji62$7Tv#tYCd<*Y~H+4VZldnwMnRtI3$#==LuAJMv zbu3!HMLb~Kny&MeD@2^|r7AFw2j1iNN5O4W=sUeE4=^yobu5Dc8Scm!(;c*ol3bCD zp+*!>X-=qw8LeTQ1WSaD2F6kLv)UGVE8`zOzlap_zsZP6bFZ`FW` zqBGL7YMuH(`keb4=l+gokH^aYj{I+&#Q<>Zfj{Uuw#R9T*?DT7R8`XLd*pp!cPtiE zfI;#*J8`@u@+ ztuB9uGb?rG5Gxm`z$6bW!y|MKjqYnEWGQ9_R2o#Z#a c^F}y9+ZB%QN|Z@-NTOL)3h?ks@rZx_0E)r7761SM literal 0 HcmV?d00001