nephics / mat4py Goto Github PK
View Code? Open in Web Editor NEWPython module for loading and saving data in the Matlab (TM) MAT-file format
License: MIT License
Python module for loading and saving data in the Matlab (TM) MAT-file format
License: MIT License
File "C:\ProgramData\Anaconda3\lib\site-packages\mat4py\loadmat.py", line 461, in loadmat
mdict[name] = read_var_array(fd_var, endian, hdr)
File "C:\ProgramData\Anaconda3\lib\site-packages\mat4py\loadmat.py", line 368, in read_var_array
return read_struct_array(fd, endian, header)
File "C:\ProgramData\Anaconda3\lib\site-packages\mat4py\loadmat.py", line 326, in read_struct_array
data = read_var_array(fd_var, endian, vheader)
File "C:\ProgramData\Anaconda3\lib\site-packages\mat4py\loadmat.py", line 366, in read_var_array
return read_cell_array(fd, endian, header)
File "C:\ProgramData\Anaconda3\lib\site-packages\mat4py\loadmat.py", line 293, in read_cell_array
varray = read_var_array(fd_var, endian, vheader)
File "C:\ProgramData\Anaconda3\lib\site-packages\mat4py\loadmat.py", line 364, in read_var_array
return read_char_array(fd, endian, header)
File "C:\ProgramData\Anaconda3\lib\site-packages\mat4py\loadmat.py", line 342, in read_char_array
array = read_numeric_array(fd, endian, header, ['miUTF8'])
File "C:\ProgramData\Anaconda3\lib\site-packages\mat4py\loadmat.py", line 270, in read_numeric_array
data = read_elements(fd, endian, data_etypes)
File "C:\ProgramData\Anaconda3\lib\site-packages\mat4py\loadmat.py", line 179, in read_elements
.format(mtp, etypes[mtp]['n'], mtpn))
NameError: name 'mtp' is not defined
ValueError: Struct field names are too long
Hello,
thank you for your library. I would like to ask you for little modification. Nowadays it gives me two Deprecation Warnings. Namely:
loadmat.py:14 /mat4py/loadmat.py:14: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working from collections import Sequence
and
mat4py/savemat.py:15 mat4py/savemat.py:15: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working from collections import Sequence, Mapping
It could be fixed be replacing imports from
from collections import Sequence
to
try: from collections.abc import Sequence except ModuleNotFoundError: from collections import Sequence
and from
from collections import Sequence, Mapping
to
try: from collections.abc import Sequence, Mapping except ModuleNotFoundError: from collections import Sequence, Mapping
Or just check: https://stackoverflow.com/a/53978543
Could you, please, fix this issue and provide new version into pipy?
Thank you.
As from issue's title. This simple code:
from mat4py import savemat
import numpy as np
data = np.ones((10,1))
savemat('./test.mat', {'data':data})
raises an error. The error arises from numpy arrays not being an instance of Sequence. For the purposes of the library, it doesn't seem that strict Sequence requirements are necessary, so checking for hasattr(array, '__len__') and hasattr(array, '__getitem__')
or isinstance(array, Iterable)
should be enough to parse simple 2d arrays. What do you think @jcbsv @tirkarthi?
Should mat4py be able to load datetime arrays ? I get the following error when trying to do so:
mat4py.loadmat.ParseError: Got type 1, expected 5
Is version 5 not supported?
mat4py.loadmat.ParseError: Expecting miMATRIX type number 14, got 1399801946
Saving a simple test struct created in Octave
a.b = 1;
save -v7 test.mat a
and loading with loadmat
loadmat('test.mat')
returns the error
\temp\loadmat.py in read_struct_array(fd, endian, header)
315 if field_name_length > 32:
316 raise ParseError('Unexpected field name length: {}'.format(
--> 317 field_name_length))
318
319 # read field names
ParseError: Unexpected field name length: 64
scalars work fine though, and importing structs from Matlab instead of Octave (as well as loading the test.mat file into Matlab).
This package is great! It provides something so much more usable than the default scipy.io.loadmat
. But it does seem to struggle on a lot of newer matlab formats. I noticed there's a mat73
project that works great for reading the HDF5 format for .mat files in version 7.3. But it doesn't write them. At any rate, it would be nice if this project could be updated to handle newer formats and the effort not duplicated too much.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.