Saturday, 15 May 2010

arrays - python: Error with numpy.where -



arrays - python: Error with numpy.where -

i trying utilize numpy.where function follows:

x= np.where(segments==1000 , segments == 0)

and valueerror:

valueerror: truth value of array more 1 element ambiguous. utilize a.any() or a.all()

browsing through other threads, seems expected behaviour. however, not sure how reformulate using numpy.any(). cannot syntax correct.

you can build status using parenthesis , & or np.logical_and instead of and:

(segments == 1000) & (segments == 0)

or:

np.logical_and(segments == 1000, segments == 0)

python arrays numpy where

No comments:

Post a Comment