Numpy array: sequence too large
Question:
I have an array of size 11
called ‘wavelength’ and a larger array of size n
called ‘MN’. And ‘model’ is an m
by n
array.
I’m doing this:
for i in xrange(10+len(wavelength)-2):
y=np.empty(model[MN][i],float)
and getting this as an error:
File "test_prog.py", line 658, in <module>
y=np.empty(model[MN][i],float)
ValueError: sequence too large; must be smaller than 32
I’m not sure what to do about that. I’ve looked elsewhere online but I can’t find anything of obvious substance.
Answers:
sequence too large
error means that you are creating a multidimension array that has a dimension larger than 32. For example: np.empty([1]*33)
will raise this error.
Are you sure you want to create >32 dimension array? If you want to create an empty array the same shape as model[MN][i]
, you should use: empty_like()
use:
empty_like()
In your case it should be:
y=np.empty_like(model[MN][i],float)
I have an array of size 11
called ‘wavelength’ and a larger array of size n
called ‘MN’. And ‘model’ is an m
by n
array.
I’m doing this:
for i in xrange(10+len(wavelength)-2):
y=np.empty(model[MN][i],float)
and getting this as an error:
File "test_prog.py", line 658, in <module>
y=np.empty(model[MN][i],float)
ValueError: sequence too large; must be smaller than 32
I’m not sure what to do about that. I’ve looked elsewhere online but I can’t find anything of obvious substance.
sequence too large
error means that you are creating a multidimension array that has a dimension larger than 32. For example: np.empty([1]*33)
will raise this error.
Are you sure you want to create >32 dimension array? If you want to create an empty array the same shape as model[MN][i]
, you should use: empty_like()
use:
empty_like()
In your case it should be:
y=np.empty_like(model[MN][i],float)