-3

input code:

randomlabel = [(random.randint(1,10),i) for i in geneex]
sortlabel = sorted(randomlabel)
store = {}
for i,j in sortlabel:
store.setdefault(i,[])

for i,j in sortlabel:
store[i].append(j)
print store

I got the rather cryptic error message

sortlabel = sorted(randomlabel)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
5
  • Use NumPy's sorting methods. Commented Aug 1, 2014 at 5:55
  • I don't know it...:'( Commented Aug 1, 2014 at 5:58
  • I can't tell what your problem is exactly from the code in your question above but what it means is that you are trying to do something along the lines of array == True whereas you should check either if any or if all elements are True explicitly. Commented Aug 1, 2014 at 6:05
  • I used NumPy's sort, but got a error message... Commented Aug 1, 2014 at 6:25
  • The error is setting an array element with a sequence. Commented Aug 1, 2014 at 6:26

1 Answer 1

0

Here the array comparison returns the boolean expression.

The Methods any() and all() reduce values over the array.

It would work fine if you replace the code with np.allclose()

Please have a look here ..It would help you out

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

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.