from numpy import *
def distance(v1,v2):
return sqrt(((v2-v1)**2).sum())
def findmatch(wts,inputwt):
dist2 = ((wts-inputwt)**2).sum(axis=1)
idx = argmin(dist2)
return idx, sqrt(dist2[idx])
Nadav
-הודעה מקורית-
מאת: [EMAIL PROTECTED] בשם wilson
נשלח: ד 23-אפריל-08 08:00
אל:
On Wed, Apr 23, 2008 at 1:00 AM, wilson <[EMAIL PROTECTED]> wrote:
> hi
> i wrote a function to find euclidian distance between two vectors and
> applied it to the rows of a 2d array of floats as below
>
>
> from math import sqrt
> from numpy import array,sum
>
> def distance(vec1, vec2):
>
hi
i wrote a function to find euclidian distance between two vectors and
applied it to the rows of a 2d array of floats as below
from math import sqrt
from numpy import array,sum
def distance(vec1, vec2):
return sqrt(sum([(x-y)**2 for x,y in zip(vec1, vec2)]))
def findmatch(wts,inputwt):
On Tue, Apr 22, 2008 at 4:38 PM, Thomas Hrabe <[EMAIL PROTECTED]> wrote:
>
> Hi all!
>
> I am currently developing a python module in C/C++ which is supposed to
> access nd arrays as defined by the following command in python
>
> a = numpy.array([1,1,1])
>
> I want to access the array the follow
On http://www.scipy.org/JorisDeRidder I've just put an example how I
passed multidimensional Numpy arrays to C++ using ctypes. Perhaps it's
helpful for your application. I didn't put it in the cookbook yet,
because I would first like to test it a bit more. Up to now I didn't
experience an
On Tue, Apr 22, 2008 at 5:51 PM, Charles R Harris <[EMAIL PROTECTED]>
wrote:
>
>
> On Tue, Apr 22, 2008 at 4:00 PM, Travis E. Oliphant <
> [EMAIL PROTECTED]> wrote:
>
> > Stéfan van der Walt wrote:
> > > 2008/4/22 lorenzo bolla <[EMAIL PROTECTED]>:
> > >
> > >> I noticed a change in the behaviour
On Tue, Apr 22, 2008 at 4:00 PM, Travis E. Oliphant <[EMAIL PROTECTED]>
wrote:
> Stéfan van der Walt wrote:
> > 2008/4/22 lorenzo bolla <[EMAIL PROTECTED]>:
> >
> >> I noticed a change in the behaviour of numpy.asfarray between numpy
> version
> >> 1.0.5 and 1.1.0:
> >>
> >> 1.0.5
> >>
> >>
>
Stéfan van der Walt wrote:
> 2008/4/22 lorenzo bolla <[EMAIL PROTECTED]>:
>
>> I noticed a change in the behaviour of numpy.asfarray between numpy version
>> 1.0.5 and 1.1.0:
>>
>> 1.0.5
>>
>>
>> In [3]: numpy.asfarray(None)
>> Out[3]: array(nan)
>> In [4]: numpy.__version__
>> Out[4]: '1.0
Hi all!
I am currently developing a python module in C/C++ which is supposed to access
nd arrays as defined by the following command in python
a = numpy.array([1,1,1])
I want to access the array the following way and use the nd array data for
further processing in C.
mymod.doSthg(a)
The exam
On Tue, 22 Apr 2008, lorenzo bolla apparently wrote:
> M=fromfunction(lambda i,j:f(i,j,5),(1000,1000))
> P=fromfunction(lambda i,j:f(i,j,7),(1000,1000))
Maybe partial function application is nicer:
http://docs.python.org/whatsnew/pep-309.html>
fwiw,
Alan Isaac
__
Well done in python :)
Is there a "numpy way" to do that (only asking for the fun because this
solution is nice)?
Xavier, who do like lamba functions :)
> what about using lambda functions?
>
> M=fromfunction(lambda i,j:f(i,j,5),(1000,1000))
> P=fromfunction(lambda i,j:f(i,j,7),(1000,1000))
>
> L
Hi All,
I want to use nested loops in our c template processor. The least intrusive
way I see to do this is to change the repeat header slightly, i.e.
/**begin repeat
#var1= a, b, c#
#var2= d, e, f#
#nest=1#
#var3= w, x#
#var4= y, z#
*/
Where "nest" becomes a keyword. The variables then take va
what about using lambda functions?
M=fromfunction(lambda i,j:f(i,j,5),(1000,1000))
P=fromfunction(lambda i,j:f(i,j,7),(1000,1000))
L.
On Tue, Apr 22, 2008 at 8:42 PM, Gnata Xavier <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> fromfunction is fine but I have like to be able to create 2Darrays using
> a f
Hi,
fromfunction is fine but I have like to be able to create 2Darrays using
a function of i,j but also of one (or more) parameters.
Something like that :
def f(i,j,a):
return (i+j)*a #replace that by another non trivial computation
M=fromfunction(f( hum well something like i,j,a),(1000,100
This is inherent; mpl 0.90.1 is permanently incompatible with numpy 1.1,
short of each user making the change suggested below. The earliest mpl
that should work with numpy 1.1 is 0.91.2.
The change in masked array module is a major reason why numpy is getting
a version bump to 1.1.0 instead of
On Tue, Apr 22, 2008 at 4:45 AM, lorenzo bolla <[EMAIL PROTECTED]> wrote:
> the latest svn numpy version 1.1.0.dev5061 does not work with matplotlib
> 0.90.1 (version shipped with enthought distribution), ...
I believe this is fixed with 0.91.2. Please see their release notes:
http://matplotlib.s
2008/4/22 lorenzo bolla <[EMAIL PROTECTED]>:
> I noticed a change in the behaviour of numpy.asfarray between numpy version
> 1.0.5 and 1.1.0:
>
> 1.0.5
>
>
> In [3]: numpy.asfarray(None)
> Out[3]: array(nan)
> In [4]: numpy.__version__
> Out[4]: '1.0.5.dev4455'
>
> 1.1.0
>
>
> In [16]: nu
I noticed a change in the behaviour of numpy.asfarray between numpy version
1.0.5 and 1.1.0:
1.0.5
In [3]: numpy.asfarray(None)
Out[3]: array(nan)
In [4]: numpy.__version__
Out[4]: '1.0.5.dev4455'
1.1.0
In [16]: numpy.asfarray(None)
On Tue, Apr 22, 2008 at 8:15 AM, Travis E. Oliphant <[EMAIL PROTECTED]>
wrote:
> Charles R Harris wrote:
> >
> > I note that other logical operators, <, ==, do in fact return booleans
> > when operating on objects. So another fix is to write special case
> > loops for logical_{not, or, and, xor} t
I will forward it to the matplotlib-devel mailing list on your behalf.
Cheers,
Mike
lorenzo bolla wrote:
> Hello,
>
> the latest svn numpy version 1.1.0.dev5061 does not work with
> matplotlib 0.90.1 (version shipped with enthought distribution),
> unless a change in
> Python25/Lib/site-packag
Charles R Harris wrote:
>
> I note that other logical operators, <, ==, do in fact return booleans
> when operating on objects. So another fix is to write special case
> loops for logical_{not, or, and, xor} that do the same. Perhaps a
> ticket for an enhancement should be opened.
There should a
Hello,
the latest svn numpy version 1.1.0.dev5061 does not work with matplotlib
0.90.1 (version shipped with enthought distribution), unless a change in
Python25/Lib/site-packages/matplotlib-0.90.1.0003-py2.5-win32.egg/matplotlib/numerix/ma/__init__.py
is done:
$ diff __init__.py.orig __init__.py
Hi,
Sorry for announcing one more numscons release in such a short time:
this releases can finally handle the last common platform, Visual Studio
on win32. Win32 installers and source tarballs can be found on
launchpad, as usual:
https://code.launchpad.net/numpy.scons.support/0.6/0.6.3
Py
Michael Hoffman wrote:
> In the following example I can sum up lists of column indices:
>
> >>> x = numpy.arange(30)
> >>> x.shape = (6, 5)
> >>> x
> array([[ 0, 1, 2, 3, 4],
> [ 5, 6, 7, 8, 9],
> [10, 11, 12, 13, 14],
> [15, 16, 17, 18, 19],
> [20, 21, 2
24 matches
Mail list logo