[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Need Help with Distance Algorithm in Numeric



Kamilche <klachemin@xxxxxxxxxxx>:
>
> Magnus Lie Hetland wrote:
> ...
> >print second[argmin(dist(first, second[..., NewAxis]), 0)]
> >
> 
> Thanks so much for your help.  I'm trying to get it running in Python 
> 2.3, but I'm getting the following error:
> 
> >>>
> Traceback (most recent call last):
>   File "C:/Documents and Settings/Administrator/Desktop/numarray 
> distance.py", line 27, in ?
>     print second[Numeric.argmin(dist(first, second[..., 
> Numeric.NewAxis]), 0)]
> IndexError: invalid index
> >>>
> 
> Here's the code that I've modified, trying to get it to work in Numeric:

As I tried to express in the original mail ;) index arrays don't work
with Numeric. (They probably will in Numeric3, though.) So, you'll
have to do something like

  take(second, ...)

instead of

  second[...]

where "..." is the argmin stuff. (If you still can't get it to work, I
can install Numeric again, and twiddle a bit with it.)

-- 
Magnus Lie Hetland                   Fall seven times, stand up eight
http://hetland.org                                 [Japanese proverb]