I'm trying to save a matrix using the scipy.io.savemat() function. However, I'm getting the following error:
RuntimeError: maximum recursion depth exceeded while calling a Python object
Here's the complete error I'm getting:
scipy.io.savemat('path/to/file.mat',dict__)
File "C:\Python27\lib\site-packages\scipy\io\matlab\mio.py", line 207, in savemat
MW.put_variables(mdict)
File "C:\Python27\lib\site-packages\scipy\io\matlab\mio5.py", line 876, in put_variables
self._matrix_writer.write_top(var, asbytes(name), is_global)
File "C:\Python27\lib\site-packages\scipy\io\matlab\mio5.py", line 626, in write_top
self.write(arr)
File "C:\Python27\lib\site-packages\scipy\io\matlab\mio5.py", line 655, in write
self.write_cells(narr)
File "C:\Python27\lib\site-packages\scipy\io\matlab\mio5.py", line 759, in write_cells
self.write(el)
File "C:\Python27\lib\site-packages\scipy\io\matlab\mio5.py", line 655, in write
self.write_cells(narr)
File "C:\Python27\lib\site-packages\scipy\io\matlab\mio5.py", line 759, in write_cells
self.write(el)
.
.
.
File "C:\Python27\lib\site-packages\scipy\io\matlab\mio5.py", line 759, in write_cells
self.write(el)
File "C:\Python27\lib\site-packages\scipy\io\matlab\mio5.py", line 655, in write
self.write_cells(narr)
File "C:\Python27\lib\site-packages\scipy\io\matlab\mio5.py", line 758, in write_cells
for el in A:
File "C:\Python27\lib\site-packages\numpy\matrixlib\defmatrix.py", line 316, in __getitem__
out = N.ndarray.__getitem__(self, index)
File "C:\Python27\lib\site-packages\numpy\matrixlib\defmatrix.py", line 292, in __array_finalize__
if (isinstance(obj, matrix) and obj._getitem): return
RuntimeError: maximum recursion depth exceeded while calling a Python object
I tried to increase the recursion limit using sys.setrecursionlimit(10000)
but it didn't change anything. I also tried the resource.setrlimit()
fix but it didn't help neither.
Does anybody have an idea what's the problem here or why is this happening? Is there any way to fix this error? Thanks in advance for your help!
P.S: I'm getting this error on Windows and Linux!
Elie