Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong interpretation of a logical array with a length of 1 in loadmat #8567

Open
rubencalje opened this issue Mar 16, 2018 · 0 comments
Open
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.io

Comments

@rubencalje
Copy link

If I save a logical array in matlab with a length of 1 and a value of false, scipy.io.loadmat resturns an array with a value of True. This bug does not happen when the length of the logical array is larger than 1.

Reproducing code example:

In MATLAB I save a logical array with:

test = false;
save test.mat test

In Python, I then load the mat-file with:

import scipy.io as sio
mat = sio.loadmat('test.mat',matlab_compatible=True)

Error message:

This results in the following object in python

{'__globals__': [],
 '__header__': b'MATLAB 5.0 MAT-file, Platform: PCWIN, Created on: Fri Mar 16 15:05:58 2018',
 '__version__': '1.0',
 'test': array([[ True]])}

As you can see, the value is now suddenly True. When I turn off matlab_compatible in loadmat, the value of 'test' will be 2, which is also incorrect.

Scipy/Numpy/Python version information:

1.0.0 1.14.0 sys.version_info(major=3, minor=6, micro=4, releaselevel='final', serial=0)
@ilayn ilayn added defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.io labels Mar 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect A clear bug or issue that prevents SciPy from being installed or used as expected scipy.io
Projects
None yet
Development

No branches or pull requests

2 participants