Closed Argubi-Wollesen closed 2 months ago
Hello Andy! If you recently updated numpy that would explain the error. Recent versions of numpy do not allow inhomogeneous arrays (i.e., rows of a 2D array with different lengths), so is it is indeed a Numpy issue then the error you describe can be replicated with this code:
import numpy as np
np.random.seed(0)
n = [80, 90, 100]
y = [np.random.randn(nn) for nn in n]
a = np.asarray( y ) # this will generate an error in recent versions of Numpy
an easy fix to avoid the error is:
a = np.asarray( y, dtype=object )
I thought I had fixed all of these inhomogeneous errors in spm1d but I obviously overlooked the spm1d.util.interp
function so I'm sorry about that! I have just posted a new version of spm1d to GitHub and PyPi, so after updating your version the error should go away. You can update to the most recent version (0.4.29) using:
pip install spm1d --upgrade
Hi Todd, hope you are well. I ran into in error recently, which I can't solve. My code ran without any hiccups until a few month ago. Now I receive an error message, using the same data as before, so I can discard any issues with the data itself. Do you (or anyone else reading this) might knwo what is causing the error? Any changes in numpy which might cause this?
This is the error message that I receive:
File [...]\interpolater.py:43 in interpolate equal_segments = spm1d.util.interp(segments, Q=101)
File ~.conda\envs\tests\lib\site-packages\spm1d\util.py:74 in interp y = np.asarray(y)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (55,) + inhomogeneous part.
I really appreciate any suggestions.
Thanks! Andy