27

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.

8
  • 1
    Any reason you're throwing away so many values of y? Commented Jul 16, 2013 at 22:37
  • Oops, forgot that definition. See Edit. Commented Jul 16, 2013 at 22:41
  • Are you sure you're indexing model correctly? If model is m x n and MN is length n then surely you want model[:,MN]? Commented Jul 16, 2013 at 23:35
  • 12
    sequence too large error means that you are creating a multidimension array that the dimension is large that 32. For example: np.empty([1]*33) will 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(). Commented Jul 17, 2013 at 1:22
  • 2
    @HYRY this is the correct answer. Can you please post this as an answer so that people who encounter the same error can easily see it? Commented Feb 18, 2014 at 15:34

2 Answers 2

27

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()

Sign up to request clarification or add additional context in comments.

Comments

0

use:

empty_like()

In your case it should be:

y=np.empty_like(model[MN][i],float)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.