Re: [Numpy-discussion] Meshgrid with Huge Arrays

2010-10-06 Thread Nadav Horesh
You should avoid meshgrid, as the follows: ... #3D ARRAY XArray = np.arange(0, NrHorPixels, 1./sqrt(NrCellsPerPixel)) YArray = np.arange(0, NrVerPixels, 1./sqrt(NrCellsPerPixel)) Z = Amplitude*exp(-(((XArray-GaussianCenterX)**2/(2*SigmaX**2))+((YArray[:,None]-GaussianCenterY)**/(2*SigmaY**2

Re: [Numpy-discussion] Assigning complex value to real array

2010-10-06 Thread Charles R Harris
On Wed, Oct 6, 2010 at 11:07 PM, Andrew P. Mullhaupt wrote: > > I came across this gem yesterday > >>> from numpy import * > >>> R = ones((2)) > >>> R[0] = R[0] * 1j > >>> R > ...array([ 0., 1.]) > >>> R = ones((2), 'complex') > >>> R[0] = R[0] * 1j > >>> R > array([ 0.+1.j, 1.+0.j])" and I read t

Re: [Numpy-discussion] Assigning complex value to real array

2010-10-06 Thread Andrew P. Mullhaupt
On 10/7/2010 1:14 AM, sicre wrote: > > > Andrew P. Mullhaupt wrote: >> (assigning complex value to real array) > Sorry, but this post is in the wrong topic since it has nothing to do with > my question. How did this happen? I created a new subject. Best regards, Andrew Mullhaupt ___

Re: [Numpy-discussion] Assigning complex value to real array

2010-10-06 Thread sicre
Andrew P. Mullhaupt wrote: > > > I came across this gem yesterday > > > > >> from numpy import * > > >> R = ones((2)) > > >> R[0] = R[0] * 1j > > >> R > ...array([ 0., 1.]) > > >> R = ones((2), 'complex') > > >> R[0] = R[0] * 1j > > >> R >

[Numpy-discussion] Assigning complex value to real array

2010-10-06 Thread Andrew P. Mullhaupt
I came across this gem yesterday > >> from numpy import * > >> R = ones((2)) > >> R[0] = R[0] * 1j > >> R ...array([ 0., 1.]) > >> R = ones((2), 'complex') > >> R[0] = R[0] * 1j > >> R array([ 0.+1.j, 1.+0.j])" and I read that this behavior is actua

[Numpy-discussion] Meshgrid with Huge Arrays

2010-10-06 Thread sicre
I do not have good programming skills, I am trying to create a 2048x2048 3D pixel array where each pixel has 100 cells. I am using meshgrid in order to create a 3D array, then adding a gaussian function to the entire array centered in (1024,1024). I am having three types of errors: #FIRST ERROR:

[Numpy-discussion] unpack argument in loadtxt/genfromtxt does not work as documented

2010-10-06 Thread Chris Fonnesbeck
The documentation for loadtxt and genfromtxt state that the unpack argument functions as follows: If True, the returned array is transposed, so that arguments may be unpacked using x, y, z = loadtxt(...). In practice, this does not always occur. I have a csv file of mixed data types, and try impo

Re: [Numpy-discussion] known failure test decorator not treated as expected by nose

2010-10-06 Thread josef . pktd
On Wed, Oct 6, 2010 at 7:08 PM, Jonathan March wrote: > It appears that the numpy testing decorators for skipping and for > known failure should behave similarly to each other, at least from > their descriptions here: > http://projects.scipy.org/numpy/wiki/TestingGuidelines#known-failures-skipping

[Numpy-discussion] known failure test decorator not treated as expected by nose

2010-10-06 Thread Jonathan March
It appears that the numpy testing decorators for skipping and for known failure should behave similarly to each other, at least from their descriptions here: http://projects.scipy.org/numpy/wiki/TestingGuidelines#known-failures-skipping-tests Yet in the following example, run under nose, they beha

Re: [Numpy-discussion] puzzle with boolean dtype

2010-10-06 Thread Charles R Harris
On Wed, Oct 6, 2010 at 4:12 PM, Alan G Isaac wrote: > On 10/6/2010 5:52 PM, Charles R Harris wrote: > > What would you want in it's place? For consistancy, a**0 == all_true, > a**i == a, i > 0? > > Yes. > > Alan Isaac > > PS Boolean matrix powers are well defined and useful. > I found this oddity

Re: [Numpy-discussion] puzzle with boolean dtype

2010-10-06 Thread Alan G Isaac
On 10/6/2010 5:52 PM, Charles R Harris wrote: > What would you want in it's place? For consistancy, a**0 == all_true, a**i == > a, i > 0? Yes. Alan Isaac PS Boolean matrix powers are well defined and useful. I found this oddity by accidentally creating an array instead of a matrix.

Re: [Numpy-discussion] puzzle with boolean dtype

2010-10-06 Thread Charles R Harris
On Wed, Oct 6, 2010 at 3:10 PM, Alan G Isaac wrote: > Integer exponentiation fails (i.e., changes type) > with boolean dtype. See below. Expected? > > Power isn't defined for booleans, I mean, who exponentiates booleans ;) What would you want in it's place? For consistancy, a**0 == all_true, a**

Re: [Numpy-discussion] point line distance

2010-10-06 Thread Ian Mallett
Hi, A background in linear algebra helps. I just came up with this method (which, because I thought of it 5 seconds ago, I don't know if it works): Line p1, p2 Point v costheta = normalize(p2-p1) dot normalize(v-p1) dist = length(v-p1)*sin(acos(costheta) Ian ___

Re: [Numpy-discussion] point line distance

2010-10-06 Thread Zachary Pincus
Here's a good list of basic geometry algorithms: http://www.softsurfer.com/algorithms.htm Zach On Oct 6, 2010, at 5:08 PM, Renato Fabbri wrote: > supose you have a line defined by two points and a point. you want > the distance > > what are easiest possibilities? i am doing it, but its nasty'

[Numpy-discussion] puzzle with boolean dtype

2010-10-06 Thread Alan G Isaac
Integer exponentiation fails (i.e., changes type) with boolean dtype. See below. Expected? Alan Isaac >>> a = np.array([[0,1,0],[0,0,1],[1,0,0]], dtype=np.bool_) >>> a2 = a*a >>> a3 = a2*a >>> print(a3) [[False True False] [False False True] [ True False F

[Numpy-discussion] point line distance

2010-10-06 Thread Renato Fabbri
supose you have a line defined by two points and a point. you want the distance what are easiest possibilities? i am doing it, but its nasty'n ugly -- GNU/Linux User #479299 skype: fabbri.renato ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.

[Numpy-discussion] numpy on 64 bit x86_64

2010-10-06 Thread P Sanjey
Hi I have a x86_64 Fedora core 3 machine where I want to install numpy but python2.4 has been installed on this machine using Intel compilers instead of gcc Can someone tell me how I can install numpy on this architecture? Thanks ___ NumPy-Discussion m

Re: [Numpy-discussion] bug in ceil()

2010-10-06 Thread Nils Wagner
On Wed, 06 Oct 2010 19:55:00 +0200 Christian Fischer wrote: > Hi All, > > I use numpy 1.4.1 on Debian squeeze amd64. > > I noticed that ceil() is not working properly. > > If the input to ceil() is a float I expect a float to be >returned but for inputs > in (-1.0, 0.0) the result is of type

Re: [Numpy-discussion] bug in ceil()

2010-10-06 Thread Charles R Harris
On Wed, Oct 6, 2010 at 11:55 AM, Christian Fischer < cfisc...@itm.uni-stuttgart.de> wrote: > Hi All, > > I use numpy 1.4.1 on Debian squeeze amd64. > > I noticed that ceil() is not working properly. > > If the input to ceil() is a float I expect a float to be returned but for > inputs > in (-1.0,

Re: [Numpy-discussion] bug in ceil()

2010-10-06 Thread Michael Droettboom
Are you sure? In [4]: type(np.ceil(-0.0)) Out[4]: Mike On 10/06/2010 01:55 PM, Christian Fischer wrote: Hi All, I use numpy 1.4.1 on Debian squeeze amd64. I noticed that ceil() is not working properly. If the input to ceil() is a float I expect a float to be returned but for inputs in (-1.

[Numpy-discussion] bug in ceil()

2010-10-06 Thread Christian Fischer
Hi All, I use numpy 1.4.1 on Debian squeeze amd64. I noticed that ceil() is not working properly. If the input to ceil() is a float I expect a float to be returned but for inputs in (-1.0, 0.0) the result is of type integer. In [65]: np.__version__ Out[65]: '1.4.1' In [66]: np.ceil(-1.1) Out[6

Re: [Numpy-discussion] ufunc.accumulate question

2010-10-06 Thread Friedrich Romstedt
2010/10/5 Chris Withers : > Hi All, > > I can't find any docs on this behavior. > > So, I have a python function. To keep it simple, lets just do addition: > > def add(x,y): >   print x,y >   retun x+y > > So, I can turn this into a ufunc as follows: > > uadd = np.frompyfunc(add,2,1) As a side rem

Re: [Numpy-discussion] index of a value in an array

2010-10-06 Thread Jonathan Rocher
Chris, Note that >>> where(condition) actually returns a tuple (one item for each dimension of a) and each element is an array with the index of when your condition occurs. Therefore if you want to extract the index itself, you need to write idx = where(a==1)[0][0] for the first element, and where

Re: [Numpy-discussion] index of a value in an array

2010-10-06 Thread Benjamin Root
On Wed, Oct 6, 2010 at 7:23 AM, Nicolas Bigaouette wrote: > On Wed, Oct 6, 2010 at 5:26 AM, Chris Withers wrote: > >> Hi All, >> >> Given an array such as: >> >> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >> >> How can I find the index of a particular number in the array? >> >> (ie: if it was a list, I

Re: [Numpy-discussion] index of a value in an array

2010-10-06 Thread Chris Withers
On 06/10/2010 14:53, Thomas, Brian (GE Energy) wrote: > For e.g. to find index of number 1 in array a, you can say > idx = where(a==1) Exactly what we were looking for, thanks! Chris ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://ma

Re: [Numpy-discussion] index of a value in an array

2010-10-06 Thread Thomas, Brian (GE Energy)
Chris, You can use where() command to find index of a particular number in the array. For e.g. to find index of number 1 in array a, you can say idx = where(a==1) Regards, Brian -Original Message- From: numpy-discussion-boun...@scipy.org [mailto:numpy-discussion-boun...@scipy.org] On B

Re: [Numpy-discussion] index of a value in an array

2010-10-06 Thread Nicolas Bigaouette
On Wed, Oct 6, 2010 at 5:26 AM, Chris Withers wrote: > Hi All, > > Given an array such as: > > array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) > > How can I find the index of a particular number in the array? > > (ie: if it was a list, I'd do [1,2,3,4].index(3)) > > cheers, > > Chris > _

[Numpy-discussion] alter_code1.py doesn't convert (any more)?

2010-10-06 Thread Frank Thommen
Hi, I'm trying to help a user to migrate from Numeric - which he used up to now - to numpy. I found reference to alter_code1.py on http://numpy.scipy.org/old_array_packages.html. First I tried the conversion script: # python2.6 /path/to/alter_code1.py test.py and alternatively # python2.6

[Numpy-discussion] index of a value in an array

2010-10-06 Thread Chris Withers
Hi All, Given an array such as: array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) How can I find the index of a particular number in the array? (ie: if it was a list, I'd do [1,2,3,4].index(3)) cheers, Chris ___ NumPy-Discussion mailing list NumPy-Discussion@sc

Re: [Numpy-discussion] Please help on compilation fortran module using f2py

2010-10-06 Thread Pearu Peterson
Hi, On 10/06/2010 04:57 AM, Jing wrote: > Hi, everyone: > > I am new to the python numpy and f2py. I really need help on compiling > FORTRAN module using f2py. I have been searched internet without any > success. Here is my setup: I have a Ubuntu 10.04 LTS with python 2.6, > numpy 1.3.0 and f2py