Closed harry-commin-enclustra closed 5 months ago
Passing a multidimensional array (> 2D) to mat2py() currently fails silently.
mat2py()
For example, this returns false, with no error message:
a = randn(3,4,5); b = py2mat(mat2py(a)); isequal(a, b)
I think this can be fixed by simply replacing the following line with else:
else
https://github.com/Apress/python-for-matlab-development/blob/6bf5d448131fb08f2470f3c435853636aae223b2/code/matlab_py/mat2py.m#L84
This causes the example above to return true. (And it also prevents silent failures, so no need to print an error message for unhandled cases). I would expect this to work find for all the data types, but I haven't tested them all:
case {'double', 'single', ... 'uint8', 'uint16', 'uint32', 'uint64', ... 'int8', 'int16', 'int32', 'int64'}
Thanks for the bug report and PR! It will be a week or so before I can get to this but I have every intention of merging.
Sure enough it was that easy; pushed bbe0424
Passing a multidimensional array (> 2D) to
mat2py()
currently fails silently.For example, this returns false, with no error message:
I think this can be fixed by simply replacing the following line with
else
:https://github.com/Apress/python-for-matlab-development/blob/6bf5d448131fb08f2470f3c435853636aae223b2/code/matlab_py/mat2py.m#L84
This causes the example above to return true. (And it also prevents silent failures, so no need to print an error message for unhandled cases). I would expect this to work find for all the data types, but I haven't tested them all: