From jack at oratrix.nl Thu Mar 1 09:35:23 2001 From: jack at oratrix.nl (Jack Jansen) Date: Thu, 01 Mar 2001 15:35:23 +0100 Subject: [Numpy-discussion] array_getcharbuf() Message-ID: <20010301143528.F2108EA11D@oratrix.oratrix.nl> My compiler gives an error on array_getcharbuf() (in arrayobject.c), and on inspection it looks as though it is right. Array_getcharbuf() has a char **ptrptr argument, and it passes *ptrptr to array_getreadbuf(), which expects a void **. My guess is that it needs to pass ptrptr, not *ptrptr. And it definitely needs a cast... This is all from the repository sources, by the way. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen at oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | ++++ see http://www.xs4all.nl/~tank/ ++++ From doko at cs.tu-berlin.de Sat Mar 3 12:42:03 2001 From: doko at cs.tu-berlin.de (Matthias Klose) Date: Sat, 3 Mar 2001 18:42:03 +0100 (MET) Subject: [Numpy-discussion] numpy-17.3.0 build errors Message-ID: <15009.11173.794900.584047@bolero> On i386-linux I am unable to build on a machine with no previous version of numpy installed. the arrayobject.h header cannot be found. Is there a way to actually show the commands use for compiling? The build procedure then continues to build the other modules and seems to ignore the return values from the compiler runs. From paul at pfdubois.com Sat Mar 3 12:52:44 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Sat, 3 Mar 2001 09:52:44 -0800 Subject: [Numpy-discussion] numpy-17.3.0 build errors In-Reply-To: <15009.11173.794900.584047@bolero> Message-ID: This issue is fixed in cvs. You can make a directory Numeric in Include and copy all the .h files down there -- I believe that's the quick fix. -----Original Message----- From: numpy-discussion-admin at lists.sourceforge.net [mailto:numpy-discussion-admin at lists.sourceforge.net]On Behalf Of Matthias Klose Sent: Saturday, March 03, 2001 9:42 AM To: numpy-discussion at lists.sourceforge.net Subject: [Numpy-discussion] numpy-17.3.0 build errors On i386-linux I am unable to build on a machine with no previous version of numpy installed. the arrayobject.h header cannot be found. Is there a way to actually show the commands use for compiling? The build procedure then continues to build the other modules and seems to ignore the return values from the compiler runs. _______________________________________________ Numpy-discussion mailing list Numpy-discussion at lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/numpy-discussion From paul at pfdubois.com Sun Mar 4 14:09:27 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Sun, 4 Mar 2001 11:09:27 -0800 Subject: [Numpy-discussion] 18.0 release for Windows Message-ID: I made my first attempt at a Windows release, Numerical-18.0.0-Python2.1.zip. Please note it only works with Python2.1b1. Comparisons returning array results are now available, thanks to Travis and his students. I do not have time to make a source release before Spam 9 so please use CVS if you need the sources for a Unix build with 2.1b1. From paul at pfdubois.com Wed Mar 7 14:04:58 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Wed, 7 Mar 2001 11:04:58 -0800 Subject: [Numpy-discussion] RE: Numpy array matching In-Reply-To: <20010307140132.C7862@cisco.com> Message-ID: They are being held for an administrative reason, my administrator password won't work, and I haven't gotten the SourceForge people to fix it yet. I don't understand the administrative reason since I can't get in to see what it really is -- something about implicit destination, which is greek to me. I'm at Spam 9 and can't work on it. -----Original Message----- From: Sam Tannous [mailto:stannous at cisco.com] Sent: Wednesday, March 07, 2001 11:02 AM To: Paul F. Dubois Subject: Numpy array matching Hi Paul, My emails to numpy-discussion don't seem to make it. Is something wrong at sourceforge? Is it just me? Thanks, Sam -- Sam Tannous email: stannous at cisco.com ) Software Engineer phone: 919.392.2541 ( NSITE/SPLoB Tools pager: 800.365.4578 C[_] ----- Forwarded message from Sam Tannous ----- From stannous at cisco.com Wed Mar 7 13:51:55 2001 From: stannous at cisco.com (Sam Tannous) Date: Wed, 7 Mar 2001 13:51:55 -0500 Subject: array matching Message-ID: If I have a character array t: >>> t = array(['abcd','aacd','ddfa','qqcd']) >>> print t [[a b c d] [a a c d] [d d f a] [q q c d]] What's the most efficient way to create an array that contains the indexes of the rows that match a particular pattern. If I want to match a 'c' in the third column, I'd like the array to look like this: i = array([0,1,3]) Thanks, Sam ----- End forwarded message ----- From nwagner at isd.uni-stuttgart.de Thu Mar 8 10:27:31 2001 From: nwagner at isd.uni-stuttgart.de (Nils Wagner) Date: Thu, 08 Mar 2001 16:27:31 +0100 Subject: [Numpy-discussion] Riccati, Sylvester, Lyapunov matrix equations Message-ID: <3AA7A4E3.648C1B23@isd.uni-stuttgart.de> Hi, I am looking for Python (Numpy, MatPy) routines to solve matrix equations like Sylvester, Lyapunov and Riccati. Thanks in advance. Nils Wagner From gvermeul at labs.polycnrs-gre.fr Sun Mar 11 12:26:51 2001 From: gvermeul at labs.polycnrs-gre.fr (Gerard Vermeulen) Date: Sun, 11 Mar 2001 18:26:51 +0100 Subject: [Numpy-discussion] Announcing PyQwt-0.29.x: fast and easy data plotting with Python and NumPy Message-ID: <3AABB55B.DEC37A4A@labs.polycnrs-gre.fr> Hi all, I am announcing PyQwt-0.29.x: fast and easy data plotting with Python and NumPy see http://gerard.vermeulen.free.fr This is a set of Python bindings for the Qt-2.x and Qwt-0.3 (Qt Widgets for Technical Applications) C++ libraries. It allows you to create interactively 2D-plots of lists, tuples or NumPy arrays of Python floats (=C/C++ doubles). Gerard Vermeulen From mathew at fugue.jpl.nasa.gov Mon Mar 12 21:54:24 2001 From: mathew at fugue.jpl.nasa.gov (Mathew Yeates) Date: Mon, 12 Mar 2001 18:54:24 -0800 Subject: [Numpy-discussion] preventing coercion of matrix Message-ID: <200103130254.SAA19824@fugue.jpl.nasa.gov> Hi- I'm using Numpy with GL and came across the following problem. a=ones((2,2),'f') print a.itemsize() #result is 4 b=1.0*a print b.itemsize() #result is 8 1) I want to pass my array to a GL routine which can only handle floats also 2) I deal with large data sets and would prefer to keep my array of type float. Is there some to prevent the upcast? I realize Python only has double datatypes but still .... that shouldnt prevent me from have floats in my object. Any help? Mathew From focke at slac.stanford.edu Tue Mar 13 00:55:25 2001 From: focke at slac.stanford.edu (Warren Focke) Date: Mon, 12 Mar 2001 21:55:25 -0800 (PST) Subject: [Numpy-discussion] preventing coercion of matrix In-Reply-To: <200103130254.SAA19824@fugue.jpl.nasa.gov> Message-ID: That's what the savespace argument to the array constructors is for: >>> a=Numeric.array(range(4), typecode='f', savespace=1) >>> a.itemsize() 4 >>> b=a*1.0 >>> b.itemsize() 4 wbf On Mon, 12 Mar 2001, Mathew Yeates wrote: > Is there some to prevent the upcast? I realize Python only has double > datatypes but still .... that shouldnt prevent me from have floats in > my object. From lahaye at postech.edu Tue Mar 13 06:36:21 2001 From: lahaye at postech.edu (R. Lahaye) Date: Tue, 13 Mar 2001 20:36:21 +0900 Subject: [Numpy-discussion] How to uninstall Numeric-17.3.0.tar.gz Message-ID: <3AAE0635.668CCDAB@postech.edu> Hi, [ I'm not a member of this list, please forward reply also to my personal email address ] First of all, I'm not at all familiar with python or numeric python. I need Numeric for testing a software package on my Linux PC. I only needed to try the sofware package, so I wanted to temporarily install Numeric, How do I do that? I mean, there seems not to be a script for uninstall!?! The scripts in 17.3.0 only allow me to install. Why is the uninstall missing? Or am I overlooking something? Thanks, Rob. PS: don't tell me to go in such and such directory and delete such and such files. That would exactly be what scripts are supposed to do. From paul at pfdubois.com Tue Mar 13 10:41:19 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Tue, 13 Mar 2001 07:41:19 -0800 Subject: [Numpy-discussion] How to uninstall Numeric-17.3.0.tar.gz In-Reply-To: <3AAE0635.668CCDAB@postech.edu> Message-ID: The "Distutils" used to make the installation does not yet have an uninstall, but the distutils discussion group has been discussing this topic. I don't follow the discussion so I can't tell you where they are, just that I have skipped over a lot of messages on the topic. Meantime go to your Python root, lib/python20/site-packages, and delete Numeric.pth, and the directory Numeric. Also directories MA and FFT if you installed those. Yeah, I know, you didn't want me to tell you that. -----Original Message----- From: numpy-discussion-admin at lists.sourceforge.net [mailto:numpy-discussion-admin at lists.sourceforge.net]On Behalf Of R. Lahaye Sent: Tuesday, March 13, 2001 3:36 AM To: numpy-discussion at lists.sourceforge.net Subject: [Numpy-discussion] How to uninstall Numeric-17.3.0.tar.gz Hi, [ I'm not a member of this list, please forward reply also to my personal email address ] First of all, I'm not at all familiar with python or numeric python. I need Numeric for testing a software package on my Linux PC. I only needed to try the sofware package, so I wanted to temporarily install Numeric, How do I do that? I mean, there seems not to be a script for uninstall!?! The scripts in 17.3.0 only allow me to install. Why is the uninstall missing? Or am I overlooking something? Thanks, Rob. PS: don't tell me to go in such and such directory and delete such and such files. That would exactly be what scripts are supposed to do. _______________________________________________ Numpy-discussion mailing list Numpy-discussion at lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/numpy-discussion From Karl.Bellve at umassmed.edu Tue Mar 13 16:08:30 2001 From: Karl.Bellve at umassmed.edu (Karl Bellve) Date: Tue, 13 Mar 2001 16:08:30 -0500 Subject: [Numpy-discussion] Numpy for Windows Message-ID: <3AAE8C4E.3EF9C4D0@umassmed.edu> I am using Numpy and Python 2.1b1 as an internal scripting language for an NT application. I have the just installed the Numpy 18 Windows binaries but I believe I need the source, including arrayobject.c and arrayobject.h. I need them to link them to my application, so I can pass Numpy Arrays to python. I am not having any luck using anonymous CVS to download the current source. I wonder if the person who just released the windows binary version could also release the header files and libraries that I need to link to? -- Cheers, Karl Bellve From ehagemann at home.com Tue Mar 13 20:45:56 2001 From: ehagemann at home.com (Eric Hagemann) Date: Tue, 13 Mar 2001 20:45:56 -0500 Subject: [Numpy-discussion] conversion to complex Message-ID: <001a01c0ac28$8391be90$cfefb418@cc911046a> I have an array of floats that is an interleaved stream of complex (real/imag) values that I want to promote to complex. My current method uses the following a=array([1,2,3,4]) b = a[0:4:2] + cmath.sqrt(-1)*a[1:4:2] Is there a more elegant way ? I am hoping to avoid explicit for loops etc -------------- next part -------------- An HTML attachment was scrubbed... URL: From focke at slac.stanford.edu Tue Mar 13 20:59:32 2001 From: focke at slac.stanford.edu (Warren Focke) Date: Tue, 13 Mar 2001 17:59:32 -0800 (PST) Subject: [Numpy-discussion] conversion to complex In-Reply-To: <001a01c0ac28$8391be90$cfefb418@cc911046a> Message-ID: > >>> a=array([1,2,3,4], 'f') > >>> b=zeros(len(a)/2, 'F') > >>> b.real=a[0:4:2] > >>> b.imag=a[1:4:2] > >>> b > array([ 1.+2.j, 3.+4.j],'F') or, if you feel brave > >>> c=fromstring(a.tostring(), 'F') > >>> c > array([ 1.+2.j, 3.+4.j],'F') wbf On Tue, 13 Mar 2001, Eric Hagemann wrote: > I have an array of floats that is an interleaved stream of complex (real/imag) values that I want to promote to complex. My current method uses the following > > a=array([1,2,3,4]) > > b = a[0:4:2] + cmath.sqrt(-1)*a[1:4:2] > > Is there a more elegant way ? I am hoping to avoid explicit for loops etc > From paul at pfdubois.com Wed Mar 14 01:32:42 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Tue, 13 Mar 2001 22:32:42 -0800 Subject: [Numpy-discussion] conversion to complex In-Reply-To: Message-ID: Also b = a[0::2] + a[1::2]*1.0j -----Original Message----- From: numpy-discussion-admin at lists.sourceforge.net [mailto:numpy-discussion-admin at lists.sourceforge.net]On Behalf Of Warren Focke Sent: Tuesday, March 13, 2001 6:00 PM To: Eric Hagemann Cc: Numpy-discussion at lists.sourceforge.net Subject: Re: [Numpy-discussion] conversion to complex > >>> a=array([1,2,3,4], 'f') > >>> b=zeros(len(a)/2, 'F') > >>> b.real=a[0:4:2] > >>> b.imag=a[1:4:2] > >>> b > array([ 1.+2.j, 3.+4.j],'F') or, if you feel brave > >>> c=fromstring(a.tostring(), 'F') > >>> c > array([ 1.+2.j, 3.+4.j],'F') wbf On Tue, 13 Mar 2001, Eric Hagemann wrote: > I have an array of floats that is an interleaved stream of complex (real/imag) values that I want to promote to complex. My current method uses the following > > a=array([1,2,3,4]) > > b = a[0:4:2] + cmath.sqrt(-1)*a[1:4:2] > > Is there a more elegant way ? I am hoping to avoid explicit for loops etc > _______________________________________________ Numpy-discussion mailing list Numpy-discussion at lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/numpy-discussion From paul at pfdubois.com Wed Mar 14 09:53:42 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Wed, 14 Mar 2001 06:53:42 -0800 Subject: [Numpy-discussion] FW: numpy array matching Message-ID: The obvious approach using equal doesn't seem to work. I'll forward your request. -- Paul -----Original Message----- From: Sam Tannous [mailto:stannous at cisco.com] Sent: Wednesday, March 14, 2001 3:31 AM To: Paul F. Dubois Subject: numpy array matching Paul, I can't seem to get my question posted to the discussion list. Could you please post it for me? (Or even answer it for me?) Thanks, Sam ------------------------------------------- If I have a character array t: >>> t = array(['abcd','aacd','ddfa','qqcd']) >>> print t [[a b c d] [a a c d] [d d f a] [q q c d]] I'm trying to find the row numbers that have a 'c' in the third column (and I'm trying to avoid a 'for' loop). What's the most efficient way to create an array that contains the indexes of the rows that match a particular pattern? (using masks?) The answer should be an array ([0,1,3]) Thanks for any tips, Sam From Aureli.Soria_Frisch at ipk.fhg.de Wed Mar 14 11:34:18 2001 From: Aureli.Soria_Frisch at ipk.fhg.de (Aureli Soria Frisch) Date: Wed, 14 Mar 2001 17:34:18 +0100 Subject: [Numpy-discussion] Bug? Product of complex arrays Message-ID: Hi, It seems there is a problem when multiplying complex arrays, but maybe that is already solved for the new NumPy 17.3, is it? The product of complex arrays does not seem to be right. Code lines: >>> a=a_conj[:] >>> a array([[ 1.-0.j, 1.-1.j, 1.-2.j], [ 1.-3.j, 1.-4.j, 1.-5.j], [ 1.-6.j, 1.-7.j, 1.-8.j]]) >>> a.imag=a.imag*-1 >>> a array([[ 1.+0.j, 1.+1.j, 1.+2.j], [ 1.+3.j, 1.+4.j, 1.+5.j], [ 1.+6.j, 1.+7.j, 1.+8.j]]) >>> Numeric.multiply(a,a_conj) array([[ 1. +0.j, 0. +2.j, -3. +4.j], [ -8. +6.j, -15. +8.j, -24.+10.j], [-35.+12.j, -48.+14.j, -63.+16.j]]) where the answer should be [[1+0j,2+0j,5+0j][10+0j,... ################################# Aureli Soria Frisch Fraunhofer IPK Dept. Pattern Recognition post: Pascalstr. 8-9, 10587 Berlin, Germany e-mail:aureli at ipk.fhg.de fon: +49 30 39 00 61 50 fax: +49 30 39 17 517 ################################# From tim.hochberg at ieee.org Wed Mar 14 12:17:22 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 14 Mar 2001 10:17:22 -0700 Subject: [Numpy-discussion] Bug? Product of complex arrays References: Message-ID: <01e201c0acaa$a2161d70$87740918@CX781526B> From: "Aureli Soria Frisch" > Hi, > > It seems there is a problem when multiplying complex arrays, but maybe that > is already solved for the new NumPy 17.3, is it? > > The product of complex arrays does not seem to be right. > > Code lines: > > >>> a=a_conj[:] This is your problem here. Array's differ from lists and such in that slicing does not produce a copy. 'a' and 'a_conj' point to the same data after this operation. One way to produce a copy is to use 'a = Numeric.array(a_conj)' > >>> a > array([[ 1.-0.j, 1.-1.j, 1.-2.j], > [ 1.-3.j, 1.-4.j, 1.-5.j], > [ 1.-6.j, 1.-7.j, 1.-8.j]]) > >>> a.imag=a.imag*-1 > >>> a > array([[ 1.+0.j, 1.+1.j, 1.+2.j], > [ 1.+3.j, 1.+4.j, 1.+5.j], > [ 1.+6.j, 1.+7.j, 1.+8.j]]) If you look at a_conj now, you should see that it is the same as a. > >>> Numeric.multiply(a,a_conj) > array([[ 1. +0.j, 0. +2.j, -3. +4.j], > [ -8. +6.j, -15. +8.j, -24.+10.j], > [-35.+12.j, -48.+14.j, -63.+16.j]]) So what you have here is really a squared. So, you could get this to work by replacing slicing with array(a_conf). A much simpler way is: a = Numeric.conjugate(a_conj) a*a_conj #... Hope that clears things up for you. -tim > where the answer should be [[1+0j,2+0j,5+0j][10+0j,... > > ################################# > Aureli Soria Frisch > Fraunhofer IPK > Dept. Pattern Recognition > > post: Pascalstr. 8-9, 10587 Berlin, Germany > e-mail:aureli at ipk.fhg.de > fon: +49 30 39 00 61 50 > fax: +49 30 39 17 517 > ################################# > > > > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion at lists.sourceforge.net > http://lists.sourceforge.net/lists/listinfo/numpy-discussion From cbarker at jps.net Wed Mar 14 13:02:07 2001 From: cbarker at jps.net (Chris Barker) Date: Wed, 14 Mar 2001 10:02:07 -0800 Subject: [Numpy-discussion] FW: numpy array matching References: Message-ID: <3AAFB21F.BAFD9C98@jps.net> "Paul F. Dubois" wrote: > ------------------------------------------- > If I have a character array t: > > >>> t = array(['abcd','aacd','ddfa','qqcd']) > >>> print t > [[a b c d] > [a a c d] > [d d f a] > [q q c d]] > > I'm trying to find the row numbers that > have a 'c' in the third column > (and I'm trying to avoid a 'for' loop). > > What's the most efficient way to > create an array that contains the indexes > of the rows that match a particular pattern? > (using masks?) > > The answer should be an array ([0,1,3]) > The obvious approach using equal doesn't seem to work. I'll forward your > request. It seems that equal() does not support the char type (anyone know why not?): >>> equal(t,'c') Traceback (most recent call last): File "", line 1, in ? TypeError: function not supported for these types, and can't coerce to supported types The following is kind of an ugly kludge, but it does work: >>> from Numeric import * >>> t = array(['abcd','aacd','ddfa','qqcd']) >>> t2 = t.astype(UnsignedInt8) >>> nonzero(equal(t2,ord('c'))[:,2]) array([0, 1, 3]) -Chris -- Christopher Barker, Ph.D. cbarker at jps.net --- --- --- http://www.jps.net/cbarker -----@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Water Resources Engineering ------ @ ------ @ ------ @ Coastal and Fluvial Hydrodynamics ------- --------- -------- ------------------------------------------------------------------------ ------------------------------------------------------------------------ From cbarker at jps.net Wed Mar 14 13:13:13 2001 From: cbarker at jps.net (Chris Barker) Date: Wed, 14 Mar 2001 10:13:13 -0800 Subject: [Numpy-discussion] FW: numpy array matching References: <3AAFB21F.BAFD9C98@jps.net> Message-ID: <3AAFB4B9.927ACEF7@jps.net> Chris Barker wrote: > >>> t = array(['abcd','aacd','ddfa','qqcd']) > > >>> t2 = t.astype(UnsignedInt8) > > >>> nonzero(equal(t2,ord('c'))[:,2]) > > array([0, 1, 3]) OOPS. For a little better performance: >>> nonzero(equal(t2[:,2],ord('c'))) array([0, 1, 3]) -- Christopher Barker, Ph.D. cbarker at jps.net --- --- --- http://www.jps.net/cbarker -----@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Water Resources Engineering ------ @ ------ @ ------ @ Coastal and Fluvial Hydrodynamics ------- --------- -------- ------------------------------------------------------------------------ ------------------------------------------------------------------------ From Karl.Bellve at umassmed.edu Thu Mar 15 09:03:01 2001 From: Karl.Bellve at umassmed.edu (Karl Bellve) Date: Thu, 15 Mar 2001 09:03:01 -0500 Subject: [Numpy-discussion] Numpy and linking.... Message-ID: <3AB0CB95.AF411734@umassmed.edu> One of the things I am confused about is how to link to numpy on a windows NT. In the docs, it basically just says to include objectarray.h. But, I assume I must also include a static lib or a DLL. I also assume that the pyd files are just dlls under windows. Since they don't have the dll extension, I must manually load them. Is this correct? I just plan to export a 2D array via PyArray_FromDimsAndData. The let a user run a python script and wait for it to finish. -- Cheers, Karl Bellve ICQ # 13956200 Biomedical Imaging Group TLCA# 7938 University of Massachusetts Email: Karl.Bellve at umassmed.edu Phone: (508) 856-6514 Fax: (508) 856-1840 PGP Public key: finger kdb at molmed.umassmed.edu From paul at pfdubois.com Thu Mar 15 20:42:41 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Thu, 15 Mar 2001 17:42:41 -0800 Subject: [Numpy-discussion] Release 18.1 Message-ID: Release 18.1 is available as a Windows zip and source tar.gz I have pasted in the change notes for both Numpy itself and MA. RELEASE 18 REQUIRES PYTHON 2.1 Documents have been updated. Homepage (only) resited to a place I can work on more easily. From Karl.Bellve at umassmed.edu Fri Mar 16 10:08:09 2001 From: Karl.Bellve at umassmed.edu (Karl Bellve) Date: Fri, 16 Mar 2001 10:08:09 -0500 Subject: [Numpy-discussion] Release 18.1 References: Message-ID: <3AB22C59.653920D5@umassmed.edu> Thank you very much! "Paul F. Dubois" wrote: > > Release 18.1 is available as a Windows zip and source tar.gz > I have pasted in the change notes for both Numpy itself and MA. > > RELEASE 18 REQUIRES PYTHON 2.1 > > Documents have been updated. Homepage (only) resited to a place I can work > on more easily. > > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion at lists.sourceforge.net > http://lists.sourceforge.net/lists/listinfo/numpy-discussion -- Cheers, Karl Bellve From Aureli.Soria_Frisch at ipk.fhg.de Mon Mar 19 14:59:29 2001 From: Aureli.Soria_Frisch at ipk.fhg.de (Aureli Soria Frisch) Date: Mon, 19 Mar 2001 20:59:29 +0100 Subject: [Numpy-discussion] How operating arrays in a determined axis? In-Reply-To: Message-ID: Hello! I have a N-dimensional array A and I want to operate in one of the axis (k) with a 1 dimensional array (for instance, subtracting an array B of length k). I have looked for some solutions in the manual and did not found any. So after testing a lot I found following solution: A=Numeric.array(a) A.shape=(a1,a2,...,ak,...,aN) #where N is any int value B=Numeric.array(b) B.shape=(ak,) A_modified=Numeric.reshape(A, (a1*a2*...*aN,ak)) #ak is not included in the product result=[] for i in A_modified: result.append(i - B) and finally reshaping the result appropriately. But it does not seem neither elegant nor simple. Is there any more elegant solution? The key point is: how to operate a N-D array with a 1D in one determined axis? Thanks in advance. Regards, Aureli ################################# Aureli Soria Frisch Fraunhofer IPK Dept. Pattern Recognition post: Pascalstr. 8-9, 10587 Berlin, Germany e-mail:aureli at ipk.fhg.de fon: +49 30 39 00 61 50 fax: +49 30 39 17 517 ################################# From Aureli.Soria_Frisch at ipk.fhg.de Mon Mar 19 15:05:16 2001 From: Aureli.Soria_Frisch at ipk.fhg.de (Aureli Soria Frisch) Date: Mon, 19 Mar 2001 21:05:16 +0100 Subject: [Numpy-discussion] How operating arrays in a determined axis? Message-ID: Hello again, I have forgotten in my previous mail that I want the procedure to run independent of the value of N... So the value of N is not known during the implementation. Sorry about the duplication... >Hello! > >I have a N-dimensional array A and I want to operate in one of the axis >(k) with a 1 dimensional array (for instance, subtracting an array B of >length k). I have looked for some solutions in the manual and did not >found any. > >So after testing a lot I found following solution: > >A=Numeric.array(a) > >A.shape=(a1,a2,...,ak,...,aN) #where N is any int value > >B=Numeric.array(b) >B.shape=(ak,) > > >A_modified=Numeric.reshape(A, (a1*a2*...*aN,ak)) #ak is not included in >the product > >result=[] >for i in A_modified: > result.append(i - B) > > >and finally reshaping the result appropriately. But it does not seem >neither elegant nor simple. > >Is there any more elegant solution? The key point is: how to operate a N-D >array with a 1D in one determined axis? > >Thanks in advance. >Regards, >Aureli > ################################# Aureli Soria Frisch Fraunhofer IPK Dept. Pattern Recognition post: Pascalstr. 8-9, 10587 Berlin, Germany e-mail:aureli at ipk.fhg.de fon: +49 30 39 00 61 50 fax: +49 30 39 17 517 ################################# From jsaenz at wm.lc.ehu.es Mon Mar 19 16:25:42 2001 From: jsaenz at wm.lc.ehu.es (Jon Saenz) Date: Mon, 19 Mar 2001 22:25:42 +0100 (MET) Subject: [Numpy-discussion] How operating arrays in a determined axis? In-Reply-To: Message-ID: Probably this can help you. Look in the manual about the ... operator, too. bash-2.02$ python Python 1.6b1 (#3, Aug 30 2000, 08:32:49) [GCC 2.7.2.1] on freebsd3 Copyright (c) Corporation for National Research Initiatives. Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam. >>> from Numeric import * >>> a=array([[2,3],[4,5],[6,7]]) >>> b=array([9,10,11]) >>> a.shape (3, 2) >>> b.shape (3,) >>> print a+b[:,NewAxis] [[11 12] [14 15] [17 18]] >>> Jon Saenz. | Tfno: +34 946012470 Depto. Fisica Aplicada II | Fax: +34 944648500 Facultad de Ciencias. \\ Universidad del Pais Vasco \\ Apdo. 644 \\ 48080 - Bilbao \\ SPAIN On Mon, 19 Mar 2001, Aureli Soria Frisch wrote: > Hello! > > I have a N-dimensional array A and I want to operate in one of the axis (k) > with a 1 dimensional array (for instance, subtracting an array B of length > k). I have looked for some solutions in the manual and did not found any. > > So after testing a lot I found following solution: > > A=Numeric.array(a) > > A.shape=(a1,a2,...,ak,...,aN) #where N is any int value > > B=Numeric.array(b) > B.shape=(ak,) > > > A_modified=Numeric.reshape(A, (a1*a2*...*aN,ak)) #ak is not included in the > product > > result=[] > for i in A_modified: > result.append(i - B) > > > and finally reshaping the result appropriately. But it does not seem > neither elegant nor simple. > > Is there any more elegant solution? The key point is: how to operate a N-D > array with a 1D in one determined axis? > > Thanks in advance. > Regards, > Aureli > > > > > ################################# > Aureli Soria Frisch > Fraunhofer IPK > Dept. Pattern Recognition > > post: Pascalstr. 8-9, 10587 Berlin, Germany > e-mail:aureli at ipk.fhg.de > fon: +49 30 39 00 61 50 > fax: +49 30 39 17 517 > ################################# > > > > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion at lists.sourceforge.net > http://lists.sourceforge.net/lists/listinfo/numpy-discussion > From focke at slac.stanford.edu Mon Mar 19 16:40:54 2001 From: focke at slac.stanford.edu (Warren Focke) Date: Mon, 19 Mar 2001 13:40:54 -0800 (PST) Subject: [Numpy-discussion] How operating arrays in a determined axis? In-Reply-To: Message-ID: On Mon, 19 Mar 2001, Aureli Soria Frisch wrote: > Hello! > > I have a N-dimensional array A and I want to operate in one of the axis (k) > with a 1 dimensional array (for instance, subtracting an array B of length > k). I have looked for some solutions in the manual and did not found any. > > So after testing a lot I found following solution: > > A=Numeric.array(a) > > A.shape=(a1,a2,...,ak,...,aN) #where N is any int value > > B=Numeric.array(b) > B.shape=(ak,) newshape = [1] * len(A.shape) newshape[k] = A.shape[k] B.shape = newshape result = A - B wbf From phrxy at csv.warwick.ac.uk Mon Mar 19 17:58:30 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Mon, 19 Mar 2001 22:58:30 +0000 (GMT) Subject: [Numpy-discussion] How operating arrays in a determined axis? In-Reply-To: Message-ID: On Mon, 19 Mar 2001, Aureli Soria Frisch wrote: [...] > I have a N-dimensional array A and I want to operate in one of the axis (k) > with a 1 dimensional array (for instance, subtracting an array B of length > k). I have looked for some solutions in the manual and did not found any. [...] > Is there any more elegant solution? The key point is: how to operate a N-D > array with a 1D in one determined axis? I'm not sure I understand exactly what you want. Are you sure you don't want to do A[n1,n2,...,:,...,nN] instead? (the '...'s are just an indication of where the extra numbers would go, not the literal Numeric syntax. If so, you can use s = slice(None) # n is your list [n1, n2, n3, ..., n(k-1), n(k+1), ...,nN] n.insert(k, s) print "answer is", A[n] - B print slice.__doc__ (possibly there is an off-by-one error in the above, but you get the idea) John From hinsen at cnrs-orleans.fr Tue Mar 20 09:17:08 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: Tue, 20 Mar 2001 15:17:08 +0100 Subject: [Numpy-discussion] How operating arrays in a determined axis? In-Reply-To: (message from Aureli Soria Frisch on Mon, 19 Mar 2001 20:59:29 +0100) References: Message-ID: <200103201417.PAA05885@chinon.cnrs-orleans.fr> > I have a N-dimensional array A and I want to operate in one of the axis (k) > with a 1 dimensional array (for instance, subtracting an array B of length > k). I have looked for some solutions in the manual and did not found any. I am not sure that I understand your problem exactly, but here's the solution to what I think your problem is ;-) from Scientific.indexing import index_expression import Numeric indices = index_expression[::] + \ (len(A.shape)-k-1)*index_expression[Numeric.NewAxis] result = A-B[indices] This uses a module from ScientificPython which provides syntactic sugar for indexing. In fact, the module is so simple that I include it here: --------------------------------------------------------------------------- # A nicer way to build up index tuples for arrays. # # You can do all this with slice() plus a few special objects, # but there's a lot to remember. This version is simpler because # it uses the standard array indexing syntax. # # Written by Konrad Hinsen # last revision: 1999-7-23 # """This module provides a convenient method for constructing array indices algorithmically. It provides one importable object, 'index_expression'. For any index combination, including slicing and axis insertion, 'a[indices]' is the same as 'a[index_expression[indices]]' for any array 'a'. However, 'index_expression[indices]' can be used anywhere in Python code and returns a tuple of indexing objects that can be used in the construction of complex index expressions. Sole restriction: Slices must be specified in the double-colon form, i.e. a[::] is allowed, whereas a[:] is not. """ class _index_expression_class: import sys maxint = sys.maxint def __getitem__(self, item): if type(item) != type(()): return (item,) else: return item def __len__(self): return self.maxint def __getslice__(self, start, stop): if stop == self.maxint: stop = None return self[start:stop:None] index_expression = _index_expression_class() --------------------------------------------------------------------------- Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From Aureli.Soria_Frisch at ipk.fhg.de Thu Mar 22 05:56:19 2001 From: Aureli.Soria_Frisch at ipk.fhg.de (Aureli Soria Frisch) Date: Thu, 22 Mar 2001 11:56:19 +0100 Subject: [Numpy-discussion] How operating arrays in a determined axis? In-Reply-To: References: Message-ID: Thanks to all answers in spite of the not so understandable question. I have solved my problem NewAxis seems tome the simplest and most elegant way to solve the problem. Maybe a name like 'VirtualAxis' would clarify more the question. Regards >On Mon, 19 Mar 2001, Aureli Soria Frisch wrote: >[...] >> I have a N-dimensional array A and I want to operate in one of the axis (k) >> with a 1 dimensional array (for instance, subtracting an array B of length >> k). I have looked for some solutions in the manual and did not found any. >[...] >> Is there any more elegant solution? The key point is: how to operate a N-D >> array with a 1D in one determined axis? ################################# Aureli Soria Frisch Fraunhofer IPK Dept. Pattern Recognition post: Pascalstr. 8-9, 10587 Berlin, Germany e-mail:aureli at ipk.fhg.de fon: +49 30 39 00 61 50 fax: +49 30 39 17 517 ################################# From tavis at calrudd.com Fri Mar 23 22:27:45 2001 From: tavis at calrudd.com (Tavis Rudd) Date: Fri, 23 Mar 2001 19:27:45 -0800 Subject: [Numpy-discussion] possible bug: pickling MaskedArrays with the latest cvs version of MA Message-ID: <01032319274500.16372@lucy> Hi, I'm having difficulty pickling with the new implementation of activeattributes in the cvs version of MA. With the standard pickle module I get the this traceback: >>> import MA >>> a = MA.arange(3400) >>> fp = open('a.pickle','w') >>> from pickle import dump, load >>> dump(a,fp) Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.1/pickle.py", line 932, in dump Pickler(file, bin).dump(object) File "/usr/local/lib/python2.1/pickle.py", line 109, in dump self.save(object) File "/usr/local/lib/python2.1/pickle.py", line 211, in save f(self, object) File "/usr/local/lib/python2.1/pickle.py", line 471, in save_inst getstate = object.__getstate__ File "/usr/local/lib/python2.1/site-packages/MA/activeattr.py", line 39, in __getattr__ return d['_get'](self, name) File "/usr/local/lib/python2.1/site-packages/MA/activeattr.py", line 80, in basic_get return self.__dict__[name] KeyError: __getstate__ With the cPickle module I'm getting: >>> from cPickle import dump, load >>> dump(a,file) Traceback (most recent call last): File "", line 1, in ? cPickle.UnpickleableError: Cannot pickle objects >>> This is with python 2.1b1 and the latest cvs version of Numeric. Has anyone else had this problem? Tavis From paul at pfdubois.com Sat Mar 24 06:28:56 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Sat, 24 Mar 2001 03:28:56 -0800 Subject: [Numpy-discussion] possible bug: pickling MaskedArrays with the latest cvs version of MA In-Reply-To: <01032319274500.16372@lucy> Message-ID: I don't know if this will help but the change is that each instance stores some (unbound) method objects. In the previous release these were stored in the class object but it turns out that isn't right wrt inheritance. I haven't much experience with pickling but I will try adding a pickle test to my test suite and see if I can figure this out. -----Original Message----- From: numpy-discussion-admin at lists.sourceforge.net [mailto:numpy-discussion-admin at lists.sourceforge.net]On Behalf Of Tavis Rudd Sent: Friday, March 23, 2001 7:28 PM To: numpy-discussion at lists.sourceforge.net Subject: [Numpy-discussion] possible bug: pickling MaskedArrays with the latest cvs version of MA Hi, I'm having difficulty pickling with the new implementation of activeattributes in the cvs version of MA. With the standard pickle module I get the this traceback: >>> import MA >>> a = MA.arange(3400) >>> fp = open('a.pickle','w') >>> from pickle import dump, load >>> dump(a,fp) Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.1/pickle.py", line 932, in dump Pickler(file, bin).dump(object) File "/usr/local/lib/python2.1/pickle.py", line 109, in dump self.save(object) File "/usr/local/lib/python2.1/pickle.py", line 211, in save f(self, object) File "/usr/local/lib/python2.1/pickle.py", line 471, in save_inst getstate = object.__getstate__ File "/usr/local/lib/python2.1/site-packages/MA/activeattr.py", line 39, in __getattr__ return d['_get'](self, name) File "/usr/local/lib/python2.1/site-packages/MA/activeattr.py", line 80, in basic_get return self.__dict__[name] KeyError: __getstate__ With the cPickle module I'm getting: >>> from cPickle import dump, load >>> dump(a,file) Traceback (most recent call last): File "", line 1, in ? cPickle.UnpickleableError: Cannot pickle objects >>> This is with python 2.1b1 and the latest cvs version of Numeric. Has anyone else had this problem? Tavis _______________________________________________ Numpy-discussion mailing list Numpy-discussion at lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/numpy-discussion From paul at pfdubois.com Sat Mar 24 17:38:32 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Sat, 24 Mar 2001 14:38:32 -0800 Subject: [Numpy-discussion] Pyfort 6.3 required for Python 2.1b2 Message-ID: Pyfort-6.3, a Python/Fortran connection tool, has been released at http://pyfortran.sourceforge.net. This version is required if you are upgrading to Python 6.1b2. From paul at pfdubois.com Sat Mar 24 18:57:59 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Sat, 24 Mar 2001 15:57:59 -0800 Subject: [Numpy-discussion] For Python 6.1b2 you need a new Pyfort Message-ID: There is a new Pyfort release 6.3 that lets Pyfort work with Python 6.1b2. Please get it from http://sourceforge.net/projects/pyfortran if you are using 6.1b2. This Pyfort will work just fine with any Python version it used to work with. From jack at oratrix.nl Mon Mar 26 03:47:03 2001 From: jack at oratrix.nl (Jack Jansen) Date: Mon, 26 Mar 2001 10:47:03 +0200 Subject: [Numpy-discussion] Setup scripts need work for 2.1b2 In-Reply-To: Message by "Paul F. Dubois" , Sat, 24 Mar 2001 03:28:56 -0800 , Message-ID: <20010326084704.206FA36B2C0@snelboot.oratrix.nl> The setup scripts need a bit of massaging for compatibility with the distutils included with Python 2.1b2, distutils now insists on version information being available. I can hack some info in, but I thought I'd best leave this to people more knowledgeable than me... -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen at oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From paul at pfdubois.com Tue Mar 27 17:47:19 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Tue, 27 Mar 2001 14:47:19 -0800 Subject: [Numpy-discussion] 18.4.1 and need volunteer Message-ID: I found that in 18.4.0 I had missed a couple of spots that needed version specs to setup. (2.1b2a requires a version argument to setup; I believe this was an error and they will fix it before 2.1 final, but for now I wanted it to work and it won't hurt as the information is not used) I need a volunteer to figure out what changes are needed to make 18.4 compile with Pythons before 2.1. I think all that is needed are some #if's in the right place and then some logic in the setup to set the appropriate macro when the python version is too early. But I don't have time to do it and the new "bug release" policy for Python will increase the number of stragglers who don't go to new versions. From dubois1 at llnl.gov Wed Mar 28 13:48:45 2001 From: dubois1 at llnl.gov (Paul F. Dubois) Date: Wed, 28 Mar 2001 10:48:45 -0800 Subject: [Numpy-discussion] Numeric 19.0.0 available Message-ID: <01032811075700.01314@almanac> Numeric 19.0.0 is available in source form and Windows / Python 2.1b2 zip form. Thanks to Pete Shinners, the source should now compile with Python 2.0. Any developer who to makes a Numeric-19.0.0-Python-2.0.zip, I think the users would like that. From paul at pfdubois.com Fri Mar 30 13:05:06 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Fri, 30 Mar 2001 10:05:06 -0800 Subject: [Numpy-discussion] Update to Numeric home page Message-ID: The Numeric home page http://pfdubois.com/numeric has been updated to include: a. New HTML and PDF version of the documentation b. New Happydoc-generated documentation for the modules, using the new Happydoc. c. Description of and link to Scientific Python. d. Navigation buttons and a hit counter. numpy.sourceforge.net still exists and links to this page. The "Homepage" button on the project page goes directly to it. I moved the contents to a web site I control so that I can work on it more easily -- sourceforge sites are hard to work on due to security. This site is hosted by Yahoo and seems to perform well. Like any site, it can be down, but I think it is down less than SF. From dubois at users.sourceforge.net Fri Mar 30 13:07:13 2001 From: dubois at users.sourceforge.net (Paul F. Dubois) Date: Fri, 30 Mar 2001 10:07:13 -0800 Subject: [Numpy-discussion] RE: Scientific Python 2.2 In-Reply-To: Message-ID: You're linked now on the home page. http://pfdubois.com/numpy. I think I misspelled it in my previous message. From turner at blueskystudios.com Fri Mar 30 16:25:58 2001 From: turner at blueskystudios.com (John A. Turner) Date: Fri, 30 Mar 2001 16:25:58 -0500 Subject: [Numpy-discussion] Update to Numeric home page In-Reply-To: References: Message-ID: <15044.63974.36936.512420@denmark.blueskystudios.com> >>>>> "PFD" == Paul F Dubois : PFD> The Numeric home page http://pfdubois.com/numeric has been updated to PFD> include: PFD> PFD> a. New HTML and PDF version of the documentation PFD> b. New Happydoc-generated documentation for the modules, using the new PFD> Happydoc. PFD> c. Description of and link to Scientific Python. PFD> d. Navigation buttons and a hit counter. PFD> PFD> numpy.sourceforge.net still exists and links to this page. PFD> The "Homepage" button on the project page goes directly to it. I moved the PFD> contents to a web site I control so that I can work on it more easily -- PFD> sourceforge sites are hard to work on due to security. PFD> PFD> This site is hosted by Yahoo and seems to perform well. Like any site, it PFD> can be down, but I think it is down less than SF. and now http://www.numpy.org/ points there as well (or it will shortly) -- John A. Turner, Ph.D. Senior Research Associate Blue Sky Studios, 44 S. Broadway, White Plains, NY 10601 http://www.blueskystudios.com/ (914) 259-6319 From paul at pfdubois.com Sat Mar 31 12:32:18 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Sat, 31 Mar 2001 09:32:18 -0800 Subject: [Numpy-discussion] Update to Numeric home page In-Reply-To: <3AC5D5C2.81269DF8@noos.fr> Message-ID: Sorry, as a subsequent messgage said, that was a typo. It is http://pfdubois.com/numpy. You don't have to remember it, however; there are links on http://numpy.sourceforge.net and on http://sourceforge.net/projects/numpy and www.numpy.org points to it as well. -----Original Message----- From: arne [mailto:arne]On Behalf Of arne keller Sent: Saturday, March 31, 2001 5:04 AM To: Paul F. Dubois Cc: numpy-discussion at lists.sourceforge.net Subject: Re: [Numpy-discussion] Update to Numeric home page "Paul F. Dubois" wrote: > > The Numeric home page http://pfdubois.com/numeric has been updated to > include: > > a. New HTML and PDF version of the documentation > b. New Happydoc-generated documentation for the modules, using the new > Happydoc. > c. Description of and link to Scientific Python. > d. Navigation buttons and a hit counter. > > numpy.sourceforge.net still exists and links to this page. > The "Homepage" button on the project page goes directly to it. I moved the > contents to a web site I control so that I can work on it more easily -- > sourceforge sites are hard to work on due to security. > http://pfdubois.com/numeric > This site is hosted by Yahoo and seems to perform well. Like any site, it > can be down, but I think it is down less than SF. > > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion at lists.sourceforge.net > http://lists.sourceforge.net/lists/listinfo/numpy-discussion there is a problem with this url: http://pfdubois.com/numeric Not Found The requested URL /numeric was not found on this server. -- Arne Keller Laboratoire de Photophysique Moleculaire du CNRS, Bat. 213. Universite de Paris-Sud, 91405 Orsay Cedex, France. tel.: (33) 1 69 15 82 83 -- fax. : (33) 1 69 15 67 77 From arne at noos.fr Sat Mar 31 08:04:02 2001 From: arne at noos.fr (arne keller) Date: Sat, 31 Mar 2001 15:04:02 +0200 Subject: [Numpy-discussion] Update to Numeric home page References: Message-ID: <3AC5D5C2.81269DF8@noos.fr> "Paul F. Dubois" wrote: > > The Numeric home page http://pfdubois.com/numeric has been updated to > include: > > a. New HTML and PDF version of the documentation > b. New Happydoc-generated documentation for the modules, using the new > Happydoc. > c. Description of and link to Scientific Python. > d. Navigation buttons and a hit counter. > > numpy.sourceforge.net still exists and links to this page. > The "Homepage" button on the project page goes directly to it. I moved the > contents to a web site I control so that I can work on it more easily -- > sourceforge sites are hard to work on due to security. > http://pfdubois.com/numeric > This site is hosted by Yahoo and seems to perform well. Like any site, it > can be down, but I think it is down less than SF. > > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion at lists.sourceforge.net > http://lists.sourceforge.net/lists/listinfo/numpy-discussion there is a problem with this url: http://pfdubois.com/numeric Not Found The requested URL /numeric was not found on this server. -- Arne Keller Laboratoire de Photophysique Moleculaire du CNRS, Bat. 213. Universite de Paris-Sud, 91405 Orsay Cedex, France. tel.: (33) 1 69 15 82 83 -- fax. : (33) 1 69 15 67 77 From jack at oratrix.nl Thu Mar 1 09:35:23 2001 From: jack at oratrix.nl (Jack Jansen) Date: Thu, 01 Mar 2001 15:35:23 +0100 Subject: [Numpy-discussion] array_getcharbuf() Message-ID: <20010301143528.F2108EA11D@oratrix.oratrix.nl> My compiler gives an error on array_getcharbuf() (in arrayobject.c), and on inspection it looks as though it is right. Array_getcharbuf() has a char **ptrptr argument, and it passes *ptrptr to array_getreadbuf(), which expects a void **. My guess is that it needs to pass ptrptr, not *ptrptr. And it definitely needs a cast... This is all from the repository sources, by the way. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen at oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | ++++ see http://www.xs4all.nl/~tank/ ++++ From doko at cs.tu-berlin.de Sat Mar 3 12:42:03 2001 From: doko at cs.tu-berlin.de (Matthias Klose) Date: Sat, 3 Mar 2001 18:42:03 +0100 (MET) Subject: [Numpy-discussion] numpy-17.3.0 build errors Message-ID: <15009.11173.794900.584047@bolero> On i386-linux I am unable to build on a machine with no previous version of numpy installed. the arrayobject.h header cannot be found. Is there a way to actually show the commands use for compiling? The build procedure then continues to build the other modules and seems to ignore the return values from the compiler runs. From paul at pfdubois.com Sat Mar 3 12:52:44 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Sat, 3 Mar 2001 09:52:44 -0800 Subject: [Numpy-discussion] numpy-17.3.0 build errors In-Reply-To: <15009.11173.794900.584047@bolero> Message-ID: This issue is fixed in cvs. You can make a directory Numeric in Include and copy all the .h files down there -- I believe that's the quick fix. -----Original Message----- From: numpy-discussion-admin at lists.sourceforge.net [mailto:numpy-discussion-admin at lists.sourceforge.net]On Behalf Of Matthias Klose Sent: Saturday, March 03, 2001 9:42 AM To: numpy-discussion at lists.sourceforge.net Subject: [Numpy-discussion] numpy-17.3.0 build errors On i386-linux I am unable to build on a machine with no previous version of numpy installed. the arrayobject.h header cannot be found. Is there a way to actually show the commands use for compiling? The build procedure then continues to build the other modules and seems to ignore the return values from the compiler runs. _______________________________________________ Numpy-discussion mailing list Numpy-discussion at lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/numpy-discussion From paul at pfdubois.com Sun Mar 4 14:09:27 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Sun, 4 Mar 2001 11:09:27 -0800 Subject: [Numpy-discussion] 18.0 release for Windows Message-ID: I made my first attempt at a Windows release, Numerical-18.0.0-Python2.1.zip. Please note it only works with Python2.1b1. Comparisons returning array results are now available, thanks to Travis and his students. I do not have time to make a source release before Spam 9 so please use CVS if you need the sources for a Unix build with 2.1b1. From paul at pfdubois.com Wed Mar 7 14:04:58 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Wed, 7 Mar 2001 11:04:58 -0800 Subject: [Numpy-discussion] RE: Numpy array matching In-Reply-To: <20010307140132.C7862@cisco.com> Message-ID: They are being held for an administrative reason, my administrator password won't work, and I haven't gotten the SourceForge people to fix it yet. I don't understand the administrative reason since I can't get in to see what it really is -- something about implicit destination, which is greek to me. I'm at Spam 9 and can't work on it. -----Original Message----- From: Sam Tannous [mailto:stannous at cisco.com] Sent: Wednesday, March 07, 2001 11:02 AM To: Paul F. Dubois Subject: Numpy array matching Hi Paul, My emails to numpy-discussion don't seem to make it. Is something wrong at sourceforge? Is it just me? Thanks, Sam -- Sam Tannous email: stannous at cisco.com ) Software Engineer phone: 919.392.2541 ( NSITE/SPLoB Tools pager: 800.365.4578 C[_] ----- Forwarded message from Sam Tannous ----- From stannous at cisco.com Wed Mar 7 13:51:55 2001 From: stannous at cisco.com (Sam Tannous) Date: Wed, 7 Mar 2001 13:51:55 -0500 Subject: array matching Message-ID: If I have a character array t: >>> t = array(['abcd','aacd','ddfa','qqcd']) >>> print t [[a b c d] [a a c d] [d d f a] [q q c d]] What's the most efficient way to create an array that contains the indexes of the rows that match a particular pattern. If I want to match a 'c' in the third column, I'd like the array to look like this: i = array([0,1,3]) Thanks, Sam ----- End forwarded message ----- From nwagner at isd.uni-stuttgart.de Thu Mar 8 10:27:31 2001 From: nwagner at isd.uni-stuttgart.de (Nils Wagner) Date: Thu, 08 Mar 2001 16:27:31 +0100 Subject: [Numpy-discussion] Riccati, Sylvester, Lyapunov matrix equations Message-ID: <3AA7A4E3.648C1B23@isd.uni-stuttgart.de> Hi, I am looking for Python (Numpy, MatPy) routines to solve matrix equations like Sylvester, Lyapunov and Riccati. Thanks in advance. Nils Wagner From gvermeul at labs.polycnrs-gre.fr Sun Mar 11 12:26:51 2001 From: gvermeul at labs.polycnrs-gre.fr (Gerard Vermeulen) Date: Sun, 11 Mar 2001 18:26:51 +0100 Subject: [Numpy-discussion] Announcing PyQwt-0.29.x: fast and easy data plotting with Python and NumPy Message-ID: <3AABB55B.DEC37A4A@labs.polycnrs-gre.fr> Hi all, I am announcing PyQwt-0.29.x: fast and easy data plotting with Python and NumPy see http://gerard.vermeulen.free.fr This is a set of Python bindings for the Qt-2.x and Qwt-0.3 (Qt Widgets for Technical Applications) C++ libraries. It allows you to create interactively 2D-plots of lists, tuples or NumPy arrays of Python floats (=C/C++ doubles). Gerard Vermeulen From mathew at fugue.jpl.nasa.gov Mon Mar 12 21:54:24 2001 From: mathew at fugue.jpl.nasa.gov (Mathew Yeates) Date: Mon, 12 Mar 2001 18:54:24 -0800 Subject: [Numpy-discussion] preventing coercion of matrix Message-ID: <200103130254.SAA19824@fugue.jpl.nasa.gov> Hi- I'm using Numpy with GL and came across the following problem. a=ones((2,2),'f') print a.itemsize() #result is 4 b=1.0*a print b.itemsize() #result is 8 1) I want to pass my array to a GL routine which can only handle floats also 2) I deal with large data sets and would prefer to keep my array of type float. Is there some to prevent the upcast? I realize Python only has double datatypes but still .... that shouldnt prevent me from have floats in my object. Any help? Mathew From focke at slac.stanford.edu Tue Mar 13 00:55:25 2001 From: focke at slac.stanford.edu (Warren Focke) Date: Mon, 12 Mar 2001 21:55:25 -0800 (PST) Subject: [Numpy-discussion] preventing coercion of matrix In-Reply-To: <200103130254.SAA19824@fugue.jpl.nasa.gov> Message-ID: That's what the savespace argument to the array constructors is for: >>> a=Numeric.array(range(4), typecode='f', savespace=1) >>> a.itemsize() 4 >>> b=a*1.0 >>> b.itemsize() 4 wbf On Mon, 12 Mar 2001, Mathew Yeates wrote: > Is there some to prevent the upcast? I realize Python only has double > datatypes but still .... that shouldnt prevent me from have floats in > my object. From lahaye at postech.edu Tue Mar 13 06:36:21 2001 From: lahaye at postech.edu (R. Lahaye) Date: Tue, 13 Mar 2001 20:36:21 +0900 Subject: [Numpy-discussion] How to uninstall Numeric-17.3.0.tar.gz Message-ID: <3AAE0635.668CCDAB@postech.edu> Hi, [ I'm not a member of this list, please forward reply also to my personal email address ] First of all, I'm not at all familiar with python or numeric python. I need Numeric for testing a software package on my Linux PC. I only needed to try the sofware package, so I wanted to temporarily install Numeric, How do I do that? I mean, there seems not to be a script for uninstall!?! The scripts in 17.3.0 only allow me to install. Why is the uninstall missing? Or am I overlooking something? Thanks, Rob. PS: don't tell me to go in such and such directory and delete such and such files. That would exactly be what scripts are supposed to do. From paul at pfdubois.com Tue Mar 13 10:41:19 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Tue, 13 Mar 2001 07:41:19 -0800 Subject: [Numpy-discussion] How to uninstall Numeric-17.3.0.tar.gz In-Reply-To: <3AAE0635.668CCDAB@postech.edu> Message-ID: The "Distutils" used to make the installation does not yet have an uninstall, but the distutils discussion group has been discussing this topic. I don't follow the discussion so I can't tell you where they are, just that I have skipped over a lot of messages on the topic. Meantime go to your Python root, lib/python20/site-packages, and delete Numeric.pth, and the directory Numeric. Also directories MA and FFT if you installed those. Yeah, I know, you didn't want me to tell you that. -----Original Message----- From: numpy-discussion-admin at lists.sourceforge.net [mailto:numpy-discussion-admin at lists.sourceforge.net]On Behalf Of R. Lahaye Sent: Tuesday, March 13, 2001 3:36 AM To: numpy-discussion at lists.sourceforge.net Subject: [Numpy-discussion] How to uninstall Numeric-17.3.0.tar.gz Hi, [ I'm not a member of this list, please forward reply also to my personal email address ] First of all, I'm not at all familiar with python or numeric python. I need Numeric for testing a software package on my Linux PC. I only needed to try the sofware package, so I wanted to temporarily install Numeric, How do I do that? I mean, there seems not to be a script for uninstall!?! The scripts in 17.3.0 only allow me to install. Why is the uninstall missing? Or am I overlooking something? Thanks, Rob. PS: don't tell me to go in such and such directory and delete such and such files. That would exactly be what scripts are supposed to do. _______________________________________________ Numpy-discussion mailing list Numpy-discussion at lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/numpy-discussion From Karl.Bellve at umassmed.edu Tue Mar 13 16:08:30 2001 From: Karl.Bellve at umassmed.edu (Karl Bellve) Date: Tue, 13 Mar 2001 16:08:30 -0500 Subject: [Numpy-discussion] Numpy for Windows Message-ID: <3AAE8C4E.3EF9C4D0@umassmed.edu> I am using Numpy and Python 2.1b1 as an internal scripting language for an NT application. I have the just installed the Numpy 18 Windows binaries but I believe I need the source, including arrayobject.c and arrayobject.h. I need them to link them to my application, so I can pass Numpy Arrays to python. I am not having any luck using anonymous CVS to download the current source. I wonder if the person who just released the windows binary version could also release the header files and libraries that I need to link to? -- Cheers, Karl Bellve From ehagemann at home.com Tue Mar 13 20:45:56 2001 From: ehagemann at home.com (Eric Hagemann) Date: Tue, 13 Mar 2001 20:45:56 -0500 Subject: [Numpy-discussion] conversion to complex Message-ID: <001a01c0ac28$8391be90$cfefb418@cc911046a> I have an array of floats that is an interleaved stream of complex (real/imag) values that I want to promote to complex. My current method uses the following a=array([1,2,3,4]) b = a[0:4:2] + cmath.sqrt(-1)*a[1:4:2] Is there a more elegant way ? I am hoping to avoid explicit for loops etc -------------- next part -------------- An HTML attachment was scrubbed... URL: From focke at slac.stanford.edu Tue Mar 13 20:59:32 2001 From: focke at slac.stanford.edu (Warren Focke) Date: Tue, 13 Mar 2001 17:59:32 -0800 (PST) Subject: [Numpy-discussion] conversion to complex In-Reply-To: <001a01c0ac28$8391be90$cfefb418@cc911046a> Message-ID: > >>> a=array([1,2,3,4], 'f') > >>> b=zeros(len(a)/2, 'F') > >>> b.real=a[0:4:2] > >>> b.imag=a[1:4:2] > >>> b > array([ 1.+2.j, 3.+4.j],'F') or, if you feel brave > >>> c=fromstring(a.tostring(), 'F') > >>> c > array([ 1.+2.j, 3.+4.j],'F') wbf On Tue, 13 Mar 2001, Eric Hagemann wrote: > I have an array of floats that is an interleaved stream of complex (real/imag) values that I want to promote to complex. My current method uses the following > > a=array([1,2,3,4]) > > b = a[0:4:2] + cmath.sqrt(-1)*a[1:4:2] > > Is there a more elegant way ? I am hoping to avoid explicit for loops etc > From paul at pfdubois.com Wed Mar 14 01:32:42 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Tue, 13 Mar 2001 22:32:42 -0800 Subject: [Numpy-discussion] conversion to complex In-Reply-To: Message-ID: Also b = a[0::2] + a[1::2]*1.0j -----Original Message----- From: numpy-discussion-admin at lists.sourceforge.net [mailto:numpy-discussion-admin at lists.sourceforge.net]On Behalf Of Warren Focke Sent: Tuesday, March 13, 2001 6:00 PM To: Eric Hagemann Cc: Numpy-discussion at lists.sourceforge.net Subject: Re: [Numpy-discussion] conversion to complex > >>> a=array([1,2,3,4], 'f') > >>> b=zeros(len(a)/2, 'F') > >>> b.real=a[0:4:2] > >>> b.imag=a[1:4:2] > >>> b > array([ 1.+2.j, 3.+4.j],'F') or, if you feel brave > >>> c=fromstring(a.tostring(), 'F') > >>> c > array([ 1.+2.j, 3.+4.j],'F') wbf On Tue, 13 Mar 2001, Eric Hagemann wrote: > I have an array of floats that is an interleaved stream of complex (real/imag) values that I want to promote to complex. My current method uses the following > > a=array([1,2,3,4]) > > b = a[0:4:2] + cmath.sqrt(-1)*a[1:4:2] > > Is there a more elegant way ? I am hoping to avoid explicit for loops etc > _______________________________________________ Numpy-discussion mailing list Numpy-discussion at lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/numpy-discussion From paul at pfdubois.com Wed Mar 14 09:53:42 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Wed, 14 Mar 2001 06:53:42 -0800 Subject: [Numpy-discussion] FW: numpy array matching Message-ID: The obvious approach using equal doesn't seem to work. I'll forward your request. -- Paul -----Original Message----- From: Sam Tannous [mailto:stannous at cisco.com] Sent: Wednesday, March 14, 2001 3:31 AM To: Paul F. Dubois Subject: numpy array matching Paul, I can't seem to get my question posted to the discussion list. Could you please post it for me? (Or even answer it for me?) Thanks, Sam ------------------------------------------- If I have a character array t: >>> t = array(['abcd','aacd','ddfa','qqcd']) >>> print t [[a b c d] [a a c d] [d d f a] [q q c d]] I'm trying to find the row numbers that have a 'c' in the third column (and I'm trying to avoid a 'for' loop). What's the most efficient way to create an array that contains the indexes of the rows that match a particular pattern? (using masks?) The answer should be an array ([0,1,3]) Thanks for any tips, Sam From Aureli.Soria_Frisch at ipk.fhg.de Wed Mar 14 11:34:18 2001 From: Aureli.Soria_Frisch at ipk.fhg.de (Aureli Soria Frisch) Date: Wed, 14 Mar 2001 17:34:18 +0100 Subject: [Numpy-discussion] Bug? Product of complex arrays Message-ID: Hi, It seems there is a problem when multiplying complex arrays, but maybe that is already solved for the new NumPy 17.3, is it? The product of complex arrays does not seem to be right. Code lines: >>> a=a_conj[:] >>> a array([[ 1.-0.j, 1.-1.j, 1.-2.j], [ 1.-3.j, 1.-4.j, 1.-5.j], [ 1.-6.j, 1.-7.j, 1.-8.j]]) >>> a.imag=a.imag*-1 >>> a array([[ 1.+0.j, 1.+1.j, 1.+2.j], [ 1.+3.j, 1.+4.j, 1.+5.j], [ 1.+6.j, 1.+7.j, 1.+8.j]]) >>> Numeric.multiply(a,a_conj) array([[ 1. +0.j, 0. +2.j, -3. +4.j], [ -8. +6.j, -15. +8.j, -24.+10.j], [-35.+12.j, -48.+14.j, -63.+16.j]]) where the answer should be [[1+0j,2+0j,5+0j][10+0j,... ################################# Aureli Soria Frisch Fraunhofer IPK Dept. Pattern Recognition post: Pascalstr. 8-9, 10587 Berlin, Germany e-mail:aureli at ipk.fhg.de fon: +49 30 39 00 61 50 fax: +49 30 39 17 517 ################################# From tim.hochberg at ieee.org Wed Mar 14 12:17:22 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 14 Mar 2001 10:17:22 -0700 Subject: [Numpy-discussion] Bug? Product of complex arrays References: Message-ID: <01e201c0acaa$a2161d70$87740918@CX781526B> From: "Aureli Soria Frisch" > Hi, > > It seems there is a problem when multiplying complex arrays, but maybe that > is already solved for the new NumPy 17.3, is it? > > The product of complex arrays does not seem to be right. > > Code lines: > > >>> a=a_conj[:] This is your problem here. Array's differ from lists and such in that slicing does not produce a copy. 'a' and 'a_conj' point to the same data after this operation. One way to produce a copy is to use 'a = Numeric.array(a_conj)' > >>> a > array([[ 1.-0.j, 1.-1.j, 1.-2.j], > [ 1.-3.j, 1.-4.j, 1.-5.j], > [ 1.-6.j, 1.-7.j, 1.-8.j]]) > >>> a.imag=a.imag*-1 > >>> a > array([[ 1.+0.j, 1.+1.j, 1.+2.j], > [ 1.+3.j, 1.+4.j, 1.+5.j], > [ 1.+6.j, 1.+7.j, 1.+8.j]]) If you look at a_conj now, you should see that it is the same as a. > >>> Numeric.multiply(a,a_conj) > array([[ 1. +0.j, 0. +2.j, -3. +4.j], > [ -8. +6.j, -15. +8.j, -24.+10.j], > [-35.+12.j, -48.+14.j, -63.+16.j]]) So what you have here is really a squared. So, you could get this to work by replacing slicing with array(a_conf). A much simpler way is: a = Numeric.conjugate(a_conj) a*a_conj #... Hope that clears things up for you. -tim > where the answer should be [[1+0j,2+0j,5+0j][10+0j,... > > ################################# > Aureli Soria Frisch > Fraunhofer IPK > Dept. Pattern Recognition > > post: Pascalstr. 8-9, 10587 Berlin, Germany > e-mail:aureli at ipk.fhg.de > fon: +49 30 39 00 61 50 > fax: +49 30 39 17 517 > ################################# > > > > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion at lists.sourceforge.net > http://lists.sourceforge.net/lists/listinfo/numpy-discussion From cbarker at jps.net Wed Mar 14 13:02:07 2001 From: cbarker at jps.net (Chris Barker) Date: Wed, 14 Mar 2001 10:02:07 -0800 Subject: [Numpy-discussion] FW: numpy array matching References: Message-ID: <3AAFB21F.BAFD9C98@jps.net> "Paul F. Dubois" wrote: > ------------------------------------------- > If I have a character array t: > > >>> t = array(['abcd','aacd','ddfa','qqcd']) > >>> print t > [[a b c d] > [a a c d] > [d d f a] > [q q c d]] > > I'm trying to find the row numbers that > have a 'c' in the third column > (and I'm trying to avoid a 'for' loop). > > What's the most efficient way to > create an array that contains the indexes > of the rows that match a particular pattern? > (using masks?) > > The answer should be an array ([0,1,3]) > The obvious approach using equal doesn't seem to work. I'll forward your > request. It seems that equal() does not support the char type (anyone know why not?): >>> equal(t,'c') Traceback (most recent call last): File "", line 1, in ? TypeError: function not supported for these types, and can't coerce to supported types The following is kind of an ugly kludge, but it does work: >>> from Numeric import * >>> t = array(['abcd','aacd','ddfa','qqcd']) >>> t2 = t.astype(UnsignedInt8) >>> nonzero(equal(t2,ord('c'))[:,2]) array([0, 1, 3]) -Chris -- Christopher Barker, Ph.D. cbarker at jps.net --- --- --- http://www.jps.net/cbarker -----@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Water Resources Engineering ------ @ ------ @ ------ @ Coastal and Fluvial Hydrodynamics ------- --------- -------- ------------------------------------------------------------------------ ------------------------------------------------------------------------ From cbarker at jps.net Wed Mar 14 13:13:13 2001 From: cbarker at jps.net (Chris Barker) Date: Wed, 14 Mar 2001 10:13:13 -0800 Subject: [Numpy-discussion] FW: numpy array matching References: <3AAFB21F.BAFD9C98@jps.net> Message-ID: <3AAFB4B9.927ACEF7@jps.net> Chris Barker wrote: > >>> t = array(['abcd','aacd','ddfa','qqcd']) > > >>> t2 = t.astype(UnsignedInt8) > > >>> nonzero(equal(t2,ord('c'))[:,2]) > > array([0, 1, 3]) OOPS. For a little better performance: >>> nonzero(equal(t2[:,2],ord('c'))) array([0, 1, 3]) -- Christopher Barker, Ph.D. cbarker at jps.net --- --- --- http://www.jps.net/cbarker -----@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Water Resources Engineering ------ @ ------ @ ------ @ Coastal and Fluvial Hydrodynamics ------- --------- -------- ------------------------------------------------------------------------ ------------------------------------------------------------------------ From Karl.Bellve at umassmed.edu Thu Mar 15 09:03:01 2001 From: Karl.Bellve at umassmed.edu (Karl Bellve) Date: Thu, 15 Mar 2001 09:03:01 -0500 Subject: [Numpy-discussion] Numpy and linking.... Message-ID: <3AB0CB95.AF411734@umassmed.edu> One of the things I am confused about is how to link to numpy on a windows NT. In the docs, it basically just says to include objectarray.h. But, I assume I must also include a static lib or a DLL. I also assume that the pyd files are just dlls under windows. Since they don't have the dll extension, I must manually load them. Is this correct? I just plan to export a 2D array via PyArray_FromDimsAndData. The let a user run a python script and wait for it to finish. -- Cheers, Karl Bellve ICQ # 13956200 Biomedical Imaging Group TLCA# 7938 University of Massachusetts Email: Karl.Bellve at umassmed.edu Phone: (508) 856-6514 Fax: (508) 856-1840 PGP Public key: finger kdb at molmed.umassmed.edu From paul at pfdubois.com Thu Mar 15 20:42:41 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Thu, 15 Mar 2001 17:42:41 -0800 Subject: [Numpy-discussion] Release 18.1 Message-ID: Release 18.1 is available as a Windows zip and source tar.gz I have pasted in the change notes for both Numpy itself and MA. RELEASE 18 REQUIRES PYTHON 2.1 Documents have been updated. Homepage (only) resited to a place I can work on more easily. From Karl.Bellve at umassmed.edu Fri Mar 16 10:08:09 2001 From: Karl.Bellve at umassmed.edu (Karl Bellve) Date: Fri, 16 Mar 2001 10:08:09 -0500 Subject: [Numpy-discussion] Release 18.1 References: Message-ID: <3AB22C59.653920D5@umassmed.edu> Thank you very much! "Paul F. Dubois" wrote: > > Release 18.1 is available as a Windows zip and source tar.gz > I have pasted in the change notes for both Numpy itself and MA. > > RELEASE 18 REQUIRES PYTHON 2.1 > > Documents have been updated. Homepage (only) resited to a place I can work > on more easily. > > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion at lists.sourceforge.net > http://lists.sourceforge.net/lists/listinfo/numpy-discussion -- Cheers, Karl Bellve From Aureli.Soria_Frisch at ipk.fhg.de Mon Mar 19 14:59:29 2001 From: Aureli.Soria_Frisch at ipk.fhg.de (Aureli Soria Frisch) Date: Mon, 19 Mar 2001 20:59:29 +0100 Subject: [Numpy-discussion] How operating arrays in a determined axis? In-Reply-To: Message-ID: Hello! I have a N-dimensional array A and I want to operate in one of the axis (k) with a 1 dimensional array (for instance, subtracting an array B of length k). I have looked for some solutions in the manual and did not found any. So after testing a lot I found following solution: A=Numeric.array(a) A.shape=(a1,a2,...,ak,...,aN) #where N is any int value B=Numeric.array(b) B.shape=(ak,) A_modified=Numeric.reshape(A, (a1*a2*...*aN,ak)) #ak is not included in the product result=[] for i in A_modified: result.append(i - B) and finally reshaping the result appropriately. But it does not seem neither elegant nor simple. Is there any more elegant solution? The key point is: how to operate a N-D array with a 1D in one determined axis? Thanks in advance. Regards, Aureli ################################# Aureli Soria Frisch Fraunhofer IPK Dept. Pattern Recognition post: Pascalstr. 8-9, 10587 Berlin, Germany e-mail:aureli at ipk.fhg.de fon: +49 30 39 00 61 50 fax: +49 30 39 17 517 ################################# From Aureli.Soria_Frisch at ipk.fhg.de Mon Mar 19 15:05:16 2001 From: Aureli.Soria_Frisch at ipk.fhg.de (Aureli Soria Frisch) Date: Mon, 19 Mar 2001 21:05:16 +0100 Subject: [Numpy-discussion] How operating arrays in a determined axis? Message-ID: Hello again, I have forgotten in my previous mail that I want the procedure to run independent of the value of N... So the value of N is not known during the implementation. Sorry about the duplication... >Hello! > >I have a N-dimensional array A and I want to operate in one of the axis >(k) with a 1 dimensional array (for instance, subtracting an array B of >length k). I have looked for some solutions in the manual and did not >found any. > >So after testing a lot I found following solution: > >A=Numeric.array(a) > >A.shape=(a1,a2,...,ak,...,aN) #where N is any int value > >B=Numeric.array(b) >B.shape=(ak,) > > >A_modified=Numeric.reshape(A, (a1*a2*...*aN,ak)) #ak is not included in >the product > >result=[] >for i in A_modified: > result.append(i - B) > > >and finally reshaping the result appropriately. But it does not seem >neither elegant nor simple. > >Is there any more elegant solution? The key point is: how to operate a N-D >array with a 1D in one determined axis? > >Thanks in advance. >Regards, >Aureli > ################################# Aureli Soria Frisch Fraunhofer IPK Dept. Pattern Recognition post: Pascalstr. 8-9, 10587 Berlin, Germany e-mail:aureli at ipk.fhg.de fon: +49 30 39 00 61 50 fax: +49 30 39 17 517 ################################# From jsaenz at wm.lc.ehu.es Mon Mar 19 16:25:42 2001 From: jsaenz at wm.lc.ehu.es (Jon Saenz) Date: Mon, 19 Mar 2001 22:25:42 +0100 (MET) Subject: [Numpy-discussion] How operating arrays in a determined axis? In-Reply-To: Message-ID: Probably this can help you. Look in the manual about the ... operator, too. bash-2.02$ python Python 1.6b1 (#3, Aug 30 2000, 08:32:49) [GCC 2.7.2.1] on freebsd3 Copyright (c) Corporation for National Research Initiatives. Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam. >>> from Numeric import * >>> a=array([[2,3],[4,5],[6,7]]) >>> b=array([9,10,11]) >>> a.shape (3, 2) >>> b.shape (3,) >>> print a+b[:,NewAxis] [[11 12] [14 15] [17 18]] >>> Jon Saenz. | Tfno: +34 946012470 Depto. Fisica Aplicada II | Fax: +34 944648500 Facultad de Ciencias. \\ Universidad del Pais Vasco \\ Apdo. 644 \\ 48080 - Bilbao \\ SPAIN On Mon, 19 Mar 2001, Aureli Soria Frisch wrote: > Hello! > > I have a N-dimensional array A and I want to operate in one of the axis (k) > with a 1 dimensional array (for instance, subtracting an array B of length > k). I have looked for some solutions in the manual and did not found any. > > So after testing a lot I found following solution: > > A=Numeric.array(a) > > A.shape=(a1,a2,...,ak,...,aN) #where N is any int value > > B=Numeric.array(b) > B.shape=(ak,) > > > A_modified=Numeric.reshape(A, (a1*a2*...*aN,ak)) #ak is not included in the > product > > result=[] > for i in A_modified: > result.append(i - B) > > > and finally reshaping the result appropriately. But it does not seem > neither elegant nor simple. > > Is there any more elegant solution? The key point is: how to operate a N-D > array with a 1D in one determined axis? > > Thanks in advance. > Regards, > Aureli > > > > > ################################# > Aureli Soria Frisch > Fraunhofer IPK > Dept. Pattern Recognition > > post: Pascalstr. 8-9, 10587 Berlin, Germany > e-mail:aureli at ipk.fhg.de > fon: +49 30 39 00 61 50 > fax: +49 30 39 17 517 > ################################# > > > > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion at lists.sourceforge.net > http://lists.sourceforge.net/lists/listinfo/numpy-discussion > From focke at slac.stanford.edu Mon Mar 19 16:40:54 2001 From: focke at slac.stanford.edu (Warren Focke) Date: Mon, 19 Mar 2001 13:40:54 -0800 (PST) Subject: [Numpy-discussion] How operating arrays in a determined axis? In-Reply-To: Message-ID: On Mon, 19 Mar 2001, Aureli Soria Frisch wrote: > Hello! > > I have a N-dimensional array A and I want to operate in one of the axis (k) > with a 1 dimensional array (for instance, subtracting an array B of length > k). I have looked for some solutions in the manual and did not found any. > > So after testing a lot I found following solution: > > A=Numeric.array(a) > > A.shape=(a1,a2,...,ak,...,aN) #where N is any int value > > B=Numeric.array(b) > B.shape=(ak,) newshape = [1] * len(A.shape) newshape[k] = A.shape[k] B.shape = newshape result = A - B wbf From phrxy at csv.warwick.ac.uk Mon Mar 19 17:58:30 2001 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Mon, 19 Mar 2001 22:58:30 +0000 (GMT) Subject: [Numpy-discussion] How operating arrays in a determined axis? In-Reply-To: Message-ID: On Mon, 19 Mar 2001, Aureli Soria Frisch wrote: [...] > I have a N-dimensional array A and I want to operate in one of the axis (k) > with a 1 dimensional array (for instance, subtracting an array B of length > k). I have looked for some solutions in the manual and did not found any. [...] > Is there any more elegant solution? The key point is: how to operate a N-D > array with a 1D in one determined axis? I'm not sure I understand exactly what you want. Are you sure you don't want to do A[n1,n2,...,:,...,nN] instead? (the '...'s are just an indication of where the extra numbers would go, not the literal Numeric syntax. If so, you can use s = slice(None) # n is your list [n1, n2, n3, ..., n(k-1), n(k+1), ...,nN] n.insert(k, s) print "answer is", A[n] - B print slice.__doc__ (possibly there is an off-by-one error in the above, but you get the idea) John From hinsen at cnrs-orleans.fr Tue Mar 20 09:17:08 2001 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: Tue, 20 Mar 2001 15:17:08 +0100 Subject: [Numpy-discussion] How operating arrays in a determined axis? In-Reply-To: (message from Aureli Soria Frisch on Mon, 19 Mar 2001 20:59:29 +0100) References: Message-ID: <200103201417.PAA05885@chinon.cnrs-orleans.fr> > I have a N-dimensional array A and I want to operate in one of the axis (k) > with a 1 dimensional array (for instance, subtracting an array B of length > k). I have looked for some solutions in the manual and did not found any. I am not sure that I understand your problem exactly, but here's the solution to what I think your problem is ;-) from Scientific.indexing import index_expression import Numeric indices = index_expression[::] + \ (len(A.shape)-k-1)*index_expression[Numeric.NewAxis] result = A-B[indices] This uses a module from ScientificPython which provides syntactic sugar for indexing. In fact, the module is so simple that I include it here: --------------------------------------------------------------------------- # A nicer way to build up index tuples for arrays. # # You can do all this with slice() plus a few special objects, # but there's a lot to remember. This version is simpler because # it uses the standard array indexing syntax. # # Written by Konrad Hinsen # last revision: 1999-7-23 # """This module provides a convenient method for constructing array indices algorithmically. It provides one importable object, 'index_expression'. For any index combination, including slicing and axis insertion, 'a[indices]' is the same as 'a[index_expression[indices]]' for any array 'a'. However, 'index_expression[indices]' can be used anywhere in Python code and returns a tuple of indexing objects that can be used in the construction of complex index expressions. Sole restriction: Slices must be specified in the double-colon form, i.e. a[::] is allowed, whereas a[:] is not. """ class _index_expression_class: import sys maxint = sys.maxint def __getitem__(self, item): if type(item) != type(()): return (item,) else: return item def __len__(self): return self.maxint def __getslice__(self, start, stop): if stop == self.maxint: stop = None return self[start:stop:None] index_expression = _index_expression_class() --------------------------------------------------------------------------- Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From Aureli.Soria_Frisch at ipk.fhg.de Thu Mar 22 05:56:19 2001 From: Aureli.Soria_Frisch at ipk.fhg.de (Aureli Soria Frisch) Date: Thu, 22 Mar 2001 11:56:19 +0100 Subject: [Numpy-discussion] How operating arrays in a determined axis? In-Reply-To: References: Message-ID: Thanks to all answers in spite of the not so understandable question. I have solved my problem NewAxis seems tome the simplest and most elegant way to solve the problem. Maybe a name like 'VirtualAxis' would clarify more the question. Regards >On Mon, 19 Mar 2001, Aureli Soria Frisch wrote: >[...] >> I have a N-dimensional array A and I want to operate in one of the axis (k) >> with a 1 dimensional array (for instance, subtracting an array B of length >> k). I have looked for some solutions in the manual and did not found any. >[...] >> Is there any more elegant solution? The key point is: how to operate a N-D >> array with a 1D in one determined axis? ################################# Aureli Soria Frisch Fraunhofer IPK Dept. Pattern Recognition post: Pascalstr. 8-9, 10587 Berlin, Germany e-mail:aureli at ipk.fhg.de fon: +49 30 39 00 61 50 fax: +49 30 39 17 517 ################################# From tavis at calrudd.com Fri Mar 23 22:27:45 2001 From: tavis at calrudd.com (Tavis Rudd) Date: Fri, 23 Mar 2001 19:27:45 -0800 Subject: [Numpy-discussion] possible bug: pickling MaskedArrays with the latest cvs version of MA Message-ID: <01032319274500.16372@lucy> Hi, I'm having difficulty pickling with the new implementation of activeattributes in the cvs version of MA. With the standard pickle module I get the this traceback: >>> import MA >>> a = MA.arange(3400) >>> fp = open('a.pickle','w') >>> from pickle import dump, load >>> dump(a,fp) Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.1/pickle.py", line 932, in dump Pickler(file, bin).dump(object) File "/usr/local/lib/python2.1/pickle.py", line 109, in dump self.save(object) File "/usr/local/lib/python2.1/pickle.py", line 211, in save f(self, object) File "/usr/local/lib/python2.1/pickle.py", line 471, in save_inst getstate = object.__getstate__ File "/usr/local/lib/python2.1/site-packages/MA/activeattr.py", line 39, in __getattr__ return d['_get'](self, name) File "/usr/local/lib/python2.1/site-packages/MA/activeattr.py", line 80, in basic_get return self.__dict__[name] KeyError: __getstate__ With the cPickle module I'm getting: >>> from cPickle import dump, load >>> dump(a,file) Traceback (most recent call last): File "", line 1, in ? cPickle.UnpickleableError: Cannot pickle objects >>> This is with python 2.1b1 and the latest cvs version of Numeric. Has anyone else had this problem? Tavis From paul at pfdubois.com Sat Mar 24 06:28:56 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Sat, 24 Mar 2001 03:28:56 -0800 Subject: [Numpy-discussion] possible bug: pickling MaskedArrays with the latest cvs version of MA In-Reply-To: <01032319274500.16372@lucy> Message-ID: I don't know if this will help but the change is that each instance stores some (unbound) method objects. In the previous release these were stored in the class object but it turns out that isn't right wrt inheritance. I haven't much experience with pickling but I will try adding a pickle test to my test suite and see if I can figure this out. -----Original Message----- From: numpy-discussion-admin at lists.sourceforge.net [mailto:numpy-discussion-admin at lists.sourceforge.net]On Behalf Of Tavis Rudd Sent: Friday, March 23, 2001 7:28 PM To: numpy-discussion at lists.sourceforge.net Subject: [Numpy-discussion] possible bug: pickling MaskedArrays with the latest cvs version of MA Hi, I'm having difficulty pickling with the new implementation of activeattributes in the cvs version of MA. With the standard pickle module I get the this traceback: >>> import MA >>> a = MA.arange(3400) >>> fp = open('a.pickle','w') >>> from pickle import dump, load >>> dump(a,fp) Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.1/pickle.py", line 932, in dump Pickler(file, bin).dump(object) File "/usr/local/lib/python2.1/pickle.py", line 109, in dump self.save(object) File "/usr/local/lib/python2.1/pickle.py", line 211, in save f(self, object) File "/usr/local/lib/python2.1/pickle.py", line 471, in save_inst getstate = object.__getstate__ File "/usr/local/lib/python2.1/site-packages/MA/activeattr.py", line 39, in __getattr__ return d['_get'](self, name) File "/usr/local/lib/python2.1/site-packages/MA/activeattr.py", line 80, in basic_get return self.__dict__[name] KeyError: __getstate__ With the cPickle module I'm getting: >>> from cPickle import dump, load >>> dump(a,file) Traceback (most recent call last): File "", line 1, in ? cPickle.UnpickleableError: Cannot pickle objects >>> This is with python 2.1b1 and the latest cvs version of Numeric. Has anyone else had this problem? Tavis _______________________________________________ Numpy-discussion mailing list Numpy-discussion at lists.sourceforge.net http://lists.sourceforge.net/lists/listinfo/numpy-discussion From paul at pfdubois.com Sat Mar 24 17:38:32 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Sat, 24 Mar 2001 14:38:32 -0800 Subject: [Numpy-discussion] Pyfort 6.3 required for Python 2.1b2 Message-ID: Pyfort-6.3, a Python/Fortran connection tool, has been released at http://pyfortran.sourceforge.net. This version is required if you are upgrading to Python 6.1b2. From paul at pfdubois.com Sat Mar 24 18:57:59 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Sat, 24 Mar 2001 15:57:59 -0800 Subject: [Numpy-discussion] For Python 6.1b2 you need a new Pyfort Message-ID: There is a new Pyfort release 6.3 that lets Pyfort work with Python 6.1b2. Please get it from http://sourceforge.net/projects/pyfortran if you are using 6.1b2. This Pyfort will work just fine with any Python version it used to work with. From jack at oratrix.nl Mon Mar 26 03:47:03 2001 From: jack at oratrix.nl (Jack Jansen) Date: Mon, 26 Mar 2001 10:47:03 +0200 Subject: [Numpy-discussion] Setup scripts need work for 2.1b2 In-Reply-To: Message by "Paul F. Dubois" , Sat, 24 Mar 2001 03:28:56 -0800 , Message-ID: <20010326084704.206FA36B2C0@snelboot.oratrix.nl> The setup scripts need a bit of massaging for compatibility with the distutils included with Python 2.1b2, distutils now insists on version information being available. I can hack some info in, but I thought I'd best leave this to people more knowledgeable than me... -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen at oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From paul at pfdubois.com Tue Mar 27 17:47:19 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Tue, 27 Mar 2001 14:47:19 -0800 Subject: [Numpy-discussion] 18.4.1 and need volunteer Message-ID: I found that in 18.4.0 I had missed a couple of spots that needed version specs to setup. (2.1b2a requires a version argument to setup; I believe this was an error and they will fix it before 2.1 final, but for now I wanted it to work and it won't hurt as the information is not used) I need a volunteer to figure out what changes are needed to make 18.4 compile with Pythons before 2.1. I think all that is needed are some #if's in the right place and then some logic in the setup to set the appropriate macro when the python version is too early. But I don't have time to do it and the new "bug release" policy for Python will increase the number of stragglers who don't go to new versions. From dubois1 at llnl.gov Wed Mar 28 13:48:45 2001 From: dubois1 at llnl.gov (Paul F. Dubois) Date: Wed, 28 Mar 2001 10:48:45 -0800 Subject: [Numpy-discussion] Numeric 19.0.0 available Message-ID: <01032811075700.01314@almanac> Numeric 19.0.0 is available in source form and Windows / Python 2.1b2 zip form. Thanks to Pete Shinners, the source should now compile with Python 2.0. Any developer who to makes a Numeric-19.0.0-Python-2.0.zip, I think the users would like that. From paul at pfdubois.com Fri Mar 30 13:05:06 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Fri, 30 Mar 2001 10:05:06 -0800 Subject: [Numpy-discussion] Update to Numeric home page Message-ID: The Numeric home page http://pfdubois.com/numeric has been updated to include: a. New HTML and PDF version of the documentation b. New Happydoc-generated documentation for the modules, using the new Happydoc. c. Description of and link to Scientific Python. d. Navigation buttons and a hit counter. numpy.sourceforge.net still exists and links to this page. The "Homepage" button on the project page goes directly to it. I moved the contents to a web site I control so that I can work on it more easily -- sourceforge sites are hard to work on due to security. This site is hosted by Yahoo and seems to perform well. Like any site, it can be down, but I think it is down less than SF. From dubois at users.sourceforge.net Fri Mar 30 13:07:13 2001 From: dubois at users.sourceforge.net (Paul F. Dubois) Date: Fri, 30 Mar 2001 10:07:13 -0800 Subject: [Numpy-discussion] RE: Scientific Python 2.2 In-Reply-To: Message-ID: You're linked now on the home page. http://pfdubois.com/numpy. I think I misspelled it in my previous message. From turner at blueskystudios.com Fri Mar 30 16:25:58 2001 From: turner at blueskystudios.com (John A. Turner) Date: Fri, 30 Mar 2001 16:25:58 -0500 Subject: [Numpy-discussion] Update to Numeric home page In-Reply-To: References: Message-ID: <15044.63974.36936.512420@denmark.blueskystudios.com> >>>>> "PFD" == Paul F Dubois : PFD> The Numeric home page http://pfdubois.com/numeric has been updated to PFD> include: PFD> PFD> a. New HTML and PDF version of the documentation PFD> b. New Happydoc-generated documentation for the modules, using the new PFD> Happydoc. PFD> c. Description of and link to Scientific Python. PFD> d. Navigation buttons and a hit counter. PFD> PFD> numpy.sourceforge.net still exists and links to this page. PFD> The "Homepage" button on the project page goes directly to it. I moved the PFD> contents to a web site I control so that I can work on it more easily -- PFD> sourceforge sites are hard to work on due to security. PFD> PFD> This site is hosted by Yahoo and seems to perform well. Like any site, it PFD> can be down, but I think it is down less than SF. and now http://www.numpy.org/ points there as well (or it will shortly) -- John A. Turner, Ph.D. Senior Research Associate Blue Sky Studios, 44 S. Broadway, White Plains, NY 10601 http://www.blueskystudios.com/ (914) 259-6319 From paul at pfdubois.com Sat Mar 31 12:32:18 2001 From: paul at pfdubois.com (Paul F. Dubois) Date: Sat, 31 Mar 2001 09:32:18 -0800 Subject: [Numpy-discussion] Update to Numeric home page In-Reply-To: <3AC5D5C2.81269DF8@noos.fr> Message-ID: Sorry, as a subsequent messgage said, that was a typo. It is http://pfdubois.com/numpy. You don't have to remember it, however; there are links on http://numpy.sourceforge.net and on http://sourceforge.net/projects/numpy and www.numpy.org points to it as well. -----Original Message----- From: arne [mailto:arne]On Behalf Of arne keller Sent: Saturday, March 31, 2001 5:04 AM To: Paul F. Dubois Cc: numpy-discussion at lists.sourceforge.net Subject: Re: [Numpy-discussion] Update to Numeric home page "Paul F. Dubois" wrote: > > The Numeric home page http://pfdubois.com/numeric has been updated to > include: > > a. New HTML and PDF version of the documentation > b. New Happydoc-generated documentation for the modules, using the new > Happydoc. > c. Description of and link to Scientific Python. > d. Navigation buttons and a hit counter. > > numpy.sourceforge.net still exists and links to this page. > The "Homepage" button on the project page goes directly to it. I moved the > contents to a web site I control so that I can work on it more easily -- > sourceforge sites are hard to work on due to security. > http://pfdubois.com/numeric > This site is hosted by Yahoo and seems to perform well. Like any site, it > can be down, but I think it is down less than SF. > > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion at lists.sourceforge.net > http://lists.sourceforge.net/lists/listinfo/numpy-discussion there is a problem with this url: http://pfdubois.com/numeric Not Found The requested URL /numeric was not found on this server. -- Arne Keller Laboratoire de Photophysique Moleculaire du CNRS, Bat. 213. Universite de Paris-Sud, 91405 Orsay Cedex, France. tel.: (33) 1 69 15 82 83 -- fax. : (33) 1 69 15 67 77 From arne at noos.fr Sat Mar 31 08:04:02 2001 From: arne at noos.fr (arne keller) Date: Sat, 31 Mar 2001 15:04:02 +0200 Subject: [Numpy-discussion] Update to Numeric home page References: Message-ID: <3AC5D5C2.81269DF8@noos.fr> "Paul F. Dubois" wrote: > > The Numeric home page http://pfdubois.com/numeric has been updated to > include: > > a. New HTML and PDF version of the documentation > b. New Happydoc-generated documentation for the modules, using the new > Happydoc. > c. Description of and link to Scientific Python. > d. Navigation buttons and a hit counter. > > numpy.sourceforge.net still exists and links to this page. > The "Homepage" button on the project page goes directly to it. I moved the > contents to a web site I control so that I can work on it more easily -- > sourceforge sites are hard to work on due to security. > http://pfdubois.com/numeric > This site is hosted by Yahoo and seems to perform well. Like any site, it > can be down, but I think it is down less than SF. > > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion at lists.sourceforge.net > http://lists.sourceforge.net/lists/listinfo/numpy-discussion there is a problem with this url: http://pfdubois.com/numeric Not Found The requested URL /numeric was not found on this server. -- Arne Keller Laboratoire de Photophysique Moleculaire du CNRS, Bat. 213. Universite de Paris-Sud, 91405 Orsay Cedex, France. tel.: (33) 1 69 15 82 83 -- fax. : (33) 1 69 15 67 77