[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Need Help with Distance Algorithm in Numeric
Kamilche <klachemin@xxxxxxxxxxx>:
>
[snip]
> import Numeric
>
> # Your distance function, for measuring how similar two RGB triples
> # are. I'm just using plain ol' Euclidean distance here. Note that it
> # returns the pairwise distances for all elements in a and b (which
> # must have the same shapes).
> def dist(a, b):
> "Euclidean distance"
> return Numeric.sqrt(sum((b - a)**2, -1))
And here is your bug. Don't use sum() -- use Numeric.sum() :)
--
Magnus Lie Hetland Fall seven times, stand up eight
http://hetland.org [Japanese proverb]