Re: [Numpy-discussion] [SciPy-user] [ANN[ pysamplerate, a library to do high quality samplerate convertion
On 11/2/06, David Cournapeau <[EMAIL PROTECTED]> wrote: > (if those announcements are not welcome on the lists, please tell me) Frankly, if an announcement for a free Python signal processing library is not welcome on the scipy lists, I don't know where it would be ;) As a minor note though: please remember to make a note of this in the Topical Software wiki; it's good for that page to remain up to date with newly released packages and libraries. Thanks! f - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
[Numpy-discussion] [ANN[ pysamplerate, a library to do high quality samplerate convertion
(if those announcements are not welcome on the lists, please tell me) Hi there, I've just developed a small package to wrap Source Rabbit Code from Erik de Castro de Lopo, which is a library to do high quality samplerate conversion (http://www.mega-nerd.com/SRC/). You can download it here: http://www.ar.media.kyoto-u.ac.jp/members/david/softwares/pysamplerate/pysamplerate-0.1.tar.gz http://www.ar.media.kyoto-u.ac.jp/members/david/softwares/pysamplerate/pysamplerate-0.1.zip Example of error conversions: http://www.ar.media.kyoto-u.ac.jp/members/david/softwares/pysamplerate/example1.png Basically, you just import resample from pysamplerate, and resample(sins, fr/fs) gives you a converted signal at sampling rate fr, with fs the original sampling rate. You can also select the conversion method (eg 'sinc_best', etc...). The pydocs + examples should be enough This package can be useful for people who deal with music signal processing and co, when scipy.resample is not enough. Only float32 and float64 input are supported for now, I will polish the package when I will have some more time, cheers, David - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Converting bool to float
On 11/1/06, Robert Kern <[EMAIL PROTECTED]> wrote: Tim Hochberg wrote:> Travis Oliphant wrote: However, whether or not float32 arrays operated with Python float scalars givefloat32 or float64 arrays is tangential to my question. Does anyone actuallythink that a Python float operated with a boolean array should give a float32 result? Must we *up*cast a boolean array to float64 to preserve the precision ofthe scalar?Probably doesn't matter most of the time, I suppose, who is going to check? I tend to think doubles because they are a bit faster on the x86 architecture and because they are a pretty common default. Chuck - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy.random.ranomd_integers returning only negative numbers ?
Fernando Perez wrote: > On 11/1/06, David Cournapeau <[EMAIL PROTECTED]> wrote: > >> Hi, >> >> I want to generate some random integers,let's say in the range [- >> 2^15, 2^16]. Why doing: >> >> noise = numpy.random.random_integers(- (2 ** 15), (2 * 15), 22050) >> >> gives only negative numbers ? >> > > In [3]: noise = numpy.random.random_integers(- (2 ** 15), (2 * 15), 22050) > > In [4]: noise[noise>0].shape > Out[4]: (17,) > > In [5]: noise[noise<0].shape > Out[5]: (22033,) > > In [6]: noise = numpy.random.random_integers(-(2**15), (2 ** 15), 22050) > > In [7]: noise[noise>0].shape > Out[7]: (11006,) > > In [8]: noise[noise>0].shape > Out[8]: (11006,) > > In [9]: 17./22033 > Out[9]: 0.00077156991785049694 > > In [10]: 2.0*15/2**15 > Out[10]: 0.00091552734375 > > close enough ;) > Ok, I deserve my email to be called the most stupid email of the week... Sorry for the noise, David - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy.random.ranomd_integers returning only negative numbers ?
Keith Goodman wrote: > On 11/1/06, David Cournapeau <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I want to generate some random integers,let's say in the range [- >> 2^15, 2^16]. Why doing: >> >> noise = numpy.random.random_integers(- (2 ** 15), (2 * 15), 22050) >> >> gives only negative numbers ? > > I guess 2^15 is too big to be an int. No, it isn't. As Fernando pointed out, if David's code is what he typed here, then his upper bound is (2 * 15) == 30 not (2 ** 15) == 32768 as he intended intended. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy.random.ranomd_integers returning only negative numbers ?
On 11/1/06, David Cournapeau <[EMAIL PROTECTED]> wrote: > Hi, > > I want to generate some random integers,let's say in the range [- > 2^15, 2^16]. Why doing: > > noise = numpy.random.random_integers(- (2 ** 15), (2 * 15), 22050) > > gives only negative numbers ? I guess 2^15 is too big to be an int. Would this work? int(N.random.uniform(1e15,1e16)) - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] numpy.random.ranomd_integers returning only negative numbers ?
On 11/1/06, David Cournapeau <[EMAIL PROTECTED]> wrote: > Hi, > > I want to generate some random integers,let's say in the range [- > 2^15, 2^16]. Why doing: > > noise = numpy.random.random_integers(- (2 ** 15), (2 * 15), 22050) > > gives only negative numbers ? In [3]: noise = numpy.random.random_integers(- (2 ** 15), (2 * 15), 22050) In [4]: noise[noise>0].shape Out[4]: (17,) In [5]: noise[noise<0].shape Out[5]: (22033,) In [6]: noise = numpy.random.random_integers(-(2**15), (2 ** 15), 22050) In [7]: noise[noise>0].shape Out[7]: (11006,) In [8]: noise[noise>0].shape Out[8]: (11006,) In [9]: 17./22033 Out[9]: 0.00077156991785049694 In [10]: 2.0*15/2**15 Out[10]: 0.00091552734375 close enough ;) Cheers, f - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
[Numpy-discussion] numpy.random.ranomd_integers returning only negative numbers ?
Hi, I want to generate some random integers,let's say in the range [- 2^15, 2^16]. Why doing: noise = numpy.random.random_integers(- (2 ** 15), (2 * 15), 22050) gives only negative numbers ? Cheers, David - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Converting bool to float
Tim Hochberg wrote: > Travis Oliphant wrote: >> Robert Kern wrote: >>> Travis Oliphant wrote: It looks like 1.0-x is doing the right thing. The problem is 1.0*x for matrices is going to float64. For arrays it returns float32 just like the 1.0-x >>> Why is this the right thing? Python floats are float64. >>> >> Yeah, why indeed. Must be something with the scalar coercion code... > > This is one of those things that pops up every few years. I suspect that > the best thing to do here is to treat 1.0, and all Python floats as > having a kind (float), but no precision. Or, equivalently treat them as > the smallest precision floating point value. The rationale behind this > is that otherwise float32 array will be promoted whenever they are > multiplied by Python floating point scalars. If Python floats are > treated as Float64 for purposes of determining output precision then > anyone using float32 arrays is going to have to wrap all of their > literals in float32 to prevent inadvertent upcasting to float64. This > was the origin of the (rather clunky) numarray spacesaver flag. > > It's no skin off my nose either way, since I pretty much never use > float32, but I suspect that treating python floats equivalently to > float64 scalars would be a mistake. At the very least it deserves a bit > of discussion. Well, they *are* 64-bit floating point numbers. You simply can't get around that. That's why we now have all of the scalar types: you can get any precision scalars that you want as long as you are explicit about it (and explicit is better than implicit). The spacesaver flag was the only solution before the various scalar types existed. I'd like to suggest that the discussion already occurred some time ago and has concluded in favor of the scalar types. Downcasting should be explicit. However, whether or not float32 arrays operated with Python float scalars give float32 or float64 arrays is tangential to my question. Does anyone actually think that a Python float operated with a boolean array should give a float32 result? Must we *up*cast a boolean array to float64 to preserve the precision of the scalar? -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] dgesdd error
On 11/1/06, Charles R Harris <[EMAIL PROTECTED]> wrote: On 11/1/06, Fernando Perez < [EMAIL PROTECTED]> wrote: On 11/1/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:>> Apparently some dgesdd libraries don't actually compute the correct > value for the work-space size if requested. >> This results in an ** ILLEGAL value and program termination from LAPACK.>> I've added code in the latest SVN to that particular wrapper to make> sure the query gives back the minimums at least, but I'd like to see who > else has the problem.>> On my system, doing numpy.linalg.svd on a 25 x 50 array pulled the trigger.>> Anybody else have that problem with their lapack library?Seems fine here: Fine here also: 1.0.1.dev3416Fedora 6, ATLAS and LAPACK from extras.ChuckOh, and 32 bit. - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] dgesdd error
On 11/1/06, Fernando Perez <[EMAIL PROTECTED]> wrote: On 11/1/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:>> Apparently some dgesdd libraries don't actually compute the correct> value for the work-space size if requested. >> This results in an ** ILLEGAL value and program termination from LAPACK.>> I've added code in the latest SVN to that particular wrapper to make> sure the query gives back the minimums at least, but I'd like to see who > else has the problem.>> On my system, doing numpy.linalg.svd on a 25 x 50 array pulled the trigger.>> Anybody else have that problem with their lapack library?Seems fine here: Fine here also: 1.0.1.dev3416Fedora 6, ATLAS and LAPACK from extras.Chuck - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Converting bool to float
On Wed, Nov 01, 2006 at 08:16:59PM -0700, Tim Hochberg wrote: > Travis Oliphant wrote: > > Robert Kern wrote: > >> Travis Oliphant wrote: > >> > >>> It looks like 1.0-x is doing the right thing. > >>> > >>> The problem is 1.0*x for matrices is going to float64. For arrays it > >>> returns float32 just like the 1.0-x > >>> > >> Why is this the right thing? Python floats are float64. > >> > > Yeah, why indeed. Must be something with the scalar coercion code... > > This is one of those things that pops up every few years. I suspect that > the best thing to do here is to treat 1.0, and all Python floats as > having a kind (float), but no precision. Or, equivalently treat them as > the smallest precision floating point value. The rationale behind this > is that otherwise float32 array will be promoted whenever they are > multiplied by Python floating point scalars. If Python floats are > treated as Float64 for purposes of determining output precision then > anyone using float32 arrays is going to have to wrap all of their > literals in float32 to prevent inadvertent upcasting to float64. This > was the origin of the (rather clunky) numarray spacesaver flag. I'm one of those people who made serious use of that clunky spacesaver flag for precisely this reason. I deal with several GB arrays of 32-bit floats (or 32-bit x2 complex numbers) on a regular basis. Having automatic upcasting from scalar operations can be a royal pain. Scott -- Scott M. RansomAddress: NRAO Phone: (434) 296-0320 520 Edgemont Rd. email: [EMAIL PROTECTED] Charlottesville, VA 22903 USA GPG Fingerprint: 06A9 9553 78BE 16DB 407B FFCA 9BFA B6FF FFD3 2989 - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Reading records from file and sorting
On 11/1/06, George Sakkis <[EMAIL PROTECTED]> wrote: Albert Strasheim wrote:> Check the thread "Strange results when sorting array with fields" from> about a week back. Travis made some changes to sorting in the presence> of fields that should solve your problem, assuming your fields appear in > the order you want to sort (i.e. you want to sort f1, f2, f3 and not> something like f1, f3, f2).I'm afraid this won't help in my case; I want to sort twice, once by f1and once by f2. I guess I could make a second file with the fields swapped but this seems more messy and inefficient than Francesc'ssuggestion.Do you actually want the two different orders, or do you want to sort on the first field, then sort all the items with the same first field on the second field? Chuck - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] dgesdd error
On 11/1/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: > > Apparently some dgesdd libraries don't actually compute the correct > value for the work-space size if requested. > > This results in an ** ILLEGAL value and program termination from LAPACK. > > I've added code in the latest SVN to that particular wrapper to make > sure the query gives back the minimums at least, but I'd like to see who > else has the problem. > > On my system, doing numpy.linalg.svd on a 25 x 50 array pulled the trigger. > > Anybody else have that problem with their lapack library? Seems fine here: In [4]: N.linalg.svd(N.random.rand(25,50)); In [5]: N.linalg.svd(N.random.rand(25,50)); In [6]: N.__version__ Out[6]: '1.0.1.dev3423' Ubuntu Dapper (6.06) box, up to date. I'm using the ubuntu-supplied ATLAS and LAPACK, I can give you more info if needed. Cheers, f - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Reading records from file and sorting
Albert Strasheim wrote: > Check the thread "Strange results when sorting array with fields" from > about a week back. Travis made some changes to sorting in the presence > of fields that should solve your problem, assuming your fields appear in > the order you want to sort (i.e. you want to sort f1, f2, f3 and not > something like f1, f3, f2). I'm afraid this won't help in my case; I want to sort twice, once by f1 and once by f2. I guess I could make a second file with the fields swapped but this seems more messy and inefficient than Francesc's suggestion. George - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
[Numpy-discussion] dgesdd error
Apparently some dgesdd libraries don't actually compute the correct value for the work-space size if requested. This results in an ** ILLEGAL value and program termination from LAPACK. I've added code in the latest SVN to that particular wrapper to make sure the query gives back the minimums at least, but I'd like to see who else has the problem. On my system, doing numpy.linalg.svd on a 25 x 50 array pulled the trigger. Anybody else have that problem with their lapack library? -Travis - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Converting bool to float
On 11/1/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: Travis Oliphant wrote:> Robert Kern wrote: Travis Oliphant wrote:>>> It looks like 1.0-x is doing the right thing.>>> >>> The problem is 1.0*x for matrices is going to float64. For arrays it>>> returns float32 just like the 1.0-x>>> Why is this the right thing? Python floats are float64. >>> Yeah, why indeed. Must be something with the scalar coercion code...This is one of those things that pops up every few years. I suspect thatthe best thing to do here is to treat 1.0, and all Python floats ashaving a kind (float), but no precision. Or, equivalently treat them asthe smallest precision floating point value. The rationale behind thisis that otherwise float32 array will be promoted whenever they are multiplied by Python floating point scalars. If Python floats aretreated as Float64 for purposes of determining output precision thenanyone using float32 arrays is going to have to wrap all of theirliterals in float32 to prevent inadvertent upcasting to float64. This was the origin of the (rather clunky) numarray spacesaver flag.It's no skin off my nose either way, since I pretty much never usefloat32, but I suspect that treating python floats equivalently tofloat64 scalars would be a mistake. At the very least it deserves a bit of discussion.Well, I think that the present convention of having the array float type determine the output type when doing a binary op with a scalar makes sense. The question is what to do when the initial array is an integer type and needs to be promoted. Now I could see 1) coercing the scalar float to integer, which is probably consistent with the treatment of integer types. (boo)2) requiring explicit use of float types, i.e., float64(1.0), which is a bit clumsy.3) promoting to float64 by default and expecting the user to specify float32( 1.0) when needed.I prefer 3, as float32 is probably not the most used data type. So the rule would benumpy_int array + python_int -- type numpy_int numpy_int array + python_flt -- type float64numpy_int array + numpy_flt -- type numpy_flt numpy_flt array + python_flt -- type numpy_fltSeems a bit much to remember, but things always get complicated when you want to control the types. Mind that going from int64 to float64 can lead to loss of precision. Chuck - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Compressed index sets, generators and iterators
A. M. Archibald wrote: > On 01/11/06, Bill Baxter <[EMAIL PROTECTED]> wrote: > > >> What's the reason iterators are not supported currently? >> For instance A[range(0,4)] works for a 1d A, but A[xrange(0,4)] does not. >> Are iterators just too inefficient to bother with? >> > > If you want an iterator back, a generator comprehension will do it: > (A[i] for i in xrange(0,4)) > > If the result is to be a numpy array, the size must be known ahead of > time (so that the memory can be allocated) and specified. At this > point, and considering the overhead in calling back and forth to the > generator, the cost of converting to a list (after all, > A[list(xrange(0,40)] should work fine) isn't necessarily worth the > trouble. > Another option for converting an iterator to a sequence that might be helpful, particularly if result is large, is to use fromiter. For example: a[numpy.fromiter(xrange(0,40, 2), int)] -tim - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Compressed index sets, generators and iterators
On 01/11/06, Bill Baxter <[EMAIL PROTECTED]> wrote: > What's the reason iterators are not supported currently? > For instance A[range(0,4)] works for a 1d A, but A[xrange(0,4)] does not. > Are iterators just too inefficient to bother with? If you want an iterator back, a generator comprehension will do it: (A[i] for i in xrange(0,4)) If the result is to be a numpy array, the size must be known ahead of time (so that the memory can be allocated) and specified. At this point, and considering the overhead in calling back and forth to the generator, the cost of converting to a list (after all, A[list(xrange(0,40)] should work fine) isn't necessarily worth the trouble. A. M. Archibald - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Converting bool to float
On 11/1/06, Keith Goodman <[EMAIL PROTECTED]> wrote: On 11/1/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:> It looks like 1.0-x is doing the right thing.>> The problem is 1.0*x for matrices is going to float64. For arrays it > returns float32 just like the 1.0-x>> This can't be changed at this point until 1.1>> We will fix the bug in 1.0*x producing float64, however. I'm still not> sure what's causing it, though. I think it would be great if float64 was the default in numpy. Thatway most people wouldn't have to worry about dtypes when crunchingnumbers. And then numpy could apply for a trademark on 'it justworks'. Having to worry about dtypes makes users (me) nervous.I imagine a change like this would not be an overnight change, more ofa long-term goal.This one, from a previous thread, also makes me nervous: >> sum(M.ones((300,1)) == 1)matrix([[44]], dtype=int8)That one seems to be fixed:In [1]: sum(ones((300,1)) == 1) Out[1]: 300In [2]: (ones((300,1)) == 1).sum() Out[2]: 300The matrix version also returns a numpy scalar, however. In [20]: sum(matrix(ones((300,1)) == 1))Out[20]: 300I wonder if that is expected? Chuck - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Converting bool to float
Travis Oliphant wrote: > Robert Kern wrote: > > >> Travis Oliphant wrote: >> >> >> >> >>> It looks like 1.0-x is doing the right thing. >>> >>> The problem is 1.0*x for matrices is going to float64. For arrays it >>> returns float32 just like the 1.0-x >>> >>> >>> >> Why is this the right thing? Python floats are float64. >> >> >> > Yeah, why indeed. Must be something with the scalar coercion code... This is one of those things that pops up every few years. I suspect that the best thing to do here is to treat 1.0, and all Python floats as having a kind (float), but no precision. Or, equivalently treat them as the smallest precision floating point value. The rationale behind this is that otherwise float32 array will be promoted whenever they are multiplied by Python floating point scalars. If Python floats are treated as Float64 for purposes of determining output precision then anyone using float32 arrays is going to have to wrap all of their literals in float32 to prevent inadvertent upcasting to float64. This was the origin of the (rather clunky) numarray spacesaver flag. It's no skin off my nose either way, since I pretty much never use float32, but I suspect that treating python floats equivalently to float64 scalars would be a mistake. At the very least it deserves a bit of discussion. -tim - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Converting bool to float
On 11/1/06, Robert Kern <[EMAIL PROTECTED]> wrote: Travis Oliphant wrote:> It looks like 1.0-x is doing the right thing.>> The problem is 1.0*x for matrices is going to float64. For arrays it> returns float32 just like the 1.0-xWhy is this the right thing? Python floats are float64. Same question here. Float32 is a designer float for special occasions, float64 is for everyday use. Chuck - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Converting bool to float
On 11/1/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: > It looks like 1.0-x is doing the right thing. > > The problem is 1.0*x for matrices is going to float64. For arrays it > returns float32 just like the 1.0-x > > This can't be changed at this point until 1.1 > > We will fix the bug in 1.0*x producing float64, however. I'm still not > sure what's causing it, though. I think it would be great if float64 was the default in numpy. That way most people wouldn't have to worry about dtypes when crunching numbers. And then numpy could apply for a trademark on 'it just works'. Having to worry about dtypes makes users (me) nervous. I imagine a change like this would not be an overnight change, more of a long-term goal. This one, from a previous thread, also makes me nervous: >> sum(M.ones((300,1)) == 1) matrix([[44]], dtype=int8) But float64 might not make sense here. - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
[Numpy-discussion] Compressed index sets, generators and iterators
Has any thought been given to using compressed or functional representations of index sets?For instance there could be a where-like function that returns an object that can generate a set of indexes on the fly, rather than explicitly allocating arrays and enumerating all of the indices. What's the reason iterators are not supported currently?For instance A[range(0,4)] works for a 1d A, but A[xrange(0,4)] does not. Are iterators just too inefficient to bother with?I could imagine an iterator that generates a set of N-tuples for an N-d array being a legal indexing construct. Even something like A[idx_iterator] = value_iterator would seem to make sense. --bb - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
[Numpy-discussion] NowPlaying Topic
Web Tools or Html easiest Html guide in beginners. Cashfall Previewtop am ffb Bluegrass Dates?Brought in discovery Monsters Waiting Echo ca slipped.Business apply throughout! Crash Fuel Saving a Minivans of.Business apply throughout!Zo Poule Place net Stel am. Rate Sign Multimedia or maken heeft.Waiting Echo ca slipped apropos showcase. Jackson School Karl Mamola State Univeristy in?Waiting Echo ca slipped apropos showcase? Etc shareware is Burner Webedit Webber or friendly flexible in?Adoredinto a Pianos night Annalee of Ferys breathy. Golive new name yes bought software. Did my views.Roses Wanna am Adoredinto Pianos night! Zijn utc or sinds am.People editor a included Splash easy. Ronde hulpstuk nba Gisteren Overige a Alles zonder.Web Tools or Html easiest Html guide in beginners. Cntry Grammys Winners a.Online is gebruikers in hebben totaal am. Zin rondje kerk Basso mag weer wedstri am literatuur am.Cars Crash Fuel Saving!Than sites or intend beginner supports image creations files or offers. Schepper in Sporten Live Blijf hoogte van Deze keer bezocht of. Lot longer separate in tools insert!Claris Home focus mainly single pages.One additional received a November accepted of until filled Dickison Physical.History Articles Picks. Cashfall Previewtop am ffb Bluegrass Dates? - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] [SciPy-user] pyaudio 0.3, with docs !
One small change -- on my intel mac, I need to link to /usr/local/lib/libsndfile.1.dylib instead of the .so file. Then everything works!!! This is truely a great thing -- my two loves, numpy and audio files, together forever... -r On Oct 31, 2006, at 7:37 AM, David Cournapeau wrote: > Hi, > > I improved pyaudio last WE using indications given by various > people > on the list or privately, and as I finally got the motivation to > set-up > something which looks like a webpage, there is a doc with examples > which > show how to use it. The API to open files for writing is much > saner, and > the setup.py should be smart enough to grab all informations necessary > to the wrapper, including the location of the shared libsndfile: > > download: > http://www.ar.media.kyoto-u.ac.jp/members/david/softwares/pyaudio/ > #installation > doc + examples: > http://www.ar.media.kyoto-u.ac.jp/members/david/softwares/pyaudio/ > > I would appreciate to hear reports on platforms which are not > linux > (windows, mac os X) to see if my the setup.py works there, > > Cheers, > > David > ___ > SciPy-user mailing list > [EMAIL PROTECTED] > http://projects.scipy.org/mailman/listinfo/scipy-user Rob Hetland, Associate Professor Dept. of Oceanography, Texas A&M University http://pong.tamu.edu/~rob phone: 979-458-0096, fax: 979-845-6331 - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Reading records from file and sorting
Hey George On Tue, 31 Oct 2006, George Sakkis wrote: > Is there a more elegant and/or faster way to read some records from a > file and then sort them by different fields ? What I have now is too > specific and error-prone in general: > > import numpy as N > records = N.fromfile(a_file, dtype=N.dtype('i2,i4')) > records_by_f0 = records.take(records.getfield('i2').argsort()) > records_by_f1 = records.take(records.getfield('i4',2).argsort()) > > If there's a better way, I'd like to see it; bonus points for in-place > sorting. Check the thread "Strange results when sorting array with fields" from about a week back. Travis made some changes to sorting in the presence of fields that should solve your problem, assuming your fields appear in the order you want to sort (i.e. you want to sort f1, f2, f3 and not something like f1, f3, f2). Cheers, Albert - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Converting bool to float
Robert Kern wrote: >Travis Oliphant wrote: > > > >>It looks like 1.0-x is doing the right thing. >> >>The problem is 1.0*x for matrices is going to float64. For arrays it >>returns float32 just like the 1.0-x >> >> > >Why is this the right thing? Python floats are float64. > > Yeah, why indeed. Must be something with the scalar coercion code... -Travis - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Converting bool to float
Travis Oliphant wrote: > It looks like 1.0-x is doing the right thing. > > The problem is 1.0*x for matrices is going to float64. For arrays it > returns float32 just like the 1.0-x Why is this the right thing? Python floats are float64. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Converting bool to float
Keith Goodman wrote: >I had a hard time tracing a bug in my code. The culprit was this difference: > > > >>>x >>> >>> > >matrix([[True], >[True], >[True]], dtype=bool) > > >>>1.0 - x >>> >>> > >matrix([[ 0.], >[ 0.], >[ 0.]], dtype=float32) <--- float32 > > >>>1.0*x >>> >>> > >matrix([[ 1.], >[ 1.], >[ 1.]])< float64 > > > >>>numpy.__version__ >>> >>> >'1.0rc1' > >Any chance that 1.0 - x could return dtype = float64? > > It looks like 1.0-x is doing the right thing. The problem is 1.0*x for matrices is going to float64. For arrays it returns float32 just like the 1.0-x This can't be changed at this point until 1.1 We will fix the bug in 1.0*x producing float64, however. I'm still not sure what's causing it, though. -Travis - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Converting bool to float
Keith Goodman wrote: >I had a hard time tracing a bug in my code. The culprit was this difference: > > > >>>x >>> >>> > >matrix([[True], >[True], >[True]], dtype=bool) > > >>>1.0 - x >>> >>> > >matrix([[ 0.], >[ 0.], >[ 0.]], dtype=float32) <--- float32 > > >>>1.0*x >>> >>> > >matrix([[ 1.], >[ 1.], >[ 1.]])< float64 > > > >>>numpy.__version__ >>> >>> >'1.0rc1' > >Any chance that 1.0 - x could return dtype = float64? > > I'm surprised it doesn't. Both should follow bascially the same code-path. Perhaps there is a missing function loop or something. I'll look in to it. -Travis - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
[Numpy-discussion] Converting bool to float
I had a hard time tracing a bug in my code. The culprit was this difference: >> x matrix([[True], [True], [True]], dtype=bool) >> 1.0 - x matrix([[ 0.], [ 0.], [ 0.]], dtype=float32) <--- float32 >> 1.0*x matrix([[ 1.], [ 1.], [ 1.]])< float64 >> numpy.__version__ '1.0rc1' Any chance that 1.0 - x could return dtype = float64? - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
[Numpy-discussion] Warning: message 1GfAoO-0007im-Sh delayed 10 hours
This message was created automatically by mail delivery software. A message that you sent has not yet been delivered to one or more of its recipients after more than 10 hours on the queue on externalmx-1.sourceforge.net. The message identifier is: 1GfAoO-0007im-Sh The subject of the message is: looked like me the full sized HARLEY and began to her, with this but as The date of the message is:Wed, 01 Nov 2006 15:46:73 +0800 The address to which the message has not yet been delivered is: numpy-discussion@lists.sourceforge.net Delay reason: SMTP error from remote mailer after RCPT TO:: host mail.sourceforge.net [66.35.250.206]: 451-Could not complete sender verify callout 451-Could not complete sender verify callout for 451-. 451-The mail server(s) for the domain may be temporarily unreachable, or 451-they may be permanently unreachable from this server. In the latter case, 451-you need to change the address or create an MX record for its domain 451-if it is No action is required on your part. Delivery attempts will continue for some time, and this warning may be repeated at intervals if the message remains undelivered. Eventually the mail delivery software will give up, and when that happens, the message will be returned to you. - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Need more comments from scientific community on python-dev
On 11/2/06, A. M. Archibald <[EMAIL PROTECTED]> wrote: On 01/11/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:> And it may be a good idea to also have a get_ctype method or some-such> on the ctypes attribute so that one could get a "ctypes description" > from the NumPy data-type.It seems to me that at the python level, there's not much reason tochoose the dtypes proposal over ctypes. There is one at the C level,it seems (though I, like perhaps most of the people on python-dev, have never actually tried using either). So perhaps, to persuade thepython-dev folks, what is needed is a comparison of what has to bedone at the C level. What would it take to rewrite numpy to usectypes? There seems to be some problem with extending the type objects used by ctypes, but it's not very clear to me what that problem is(what the extensions are supposed to do).I posted a message to the thread trying to prod things in that direction. I.e. can we see a simple concrete example of the complications involved in using ctypes interface code, vs the presumably much nicer numpy/data-descriptor code. I too think that would help convince people. Just saying it's more compilcated, trust me, doesn't help when most people reading the list have never had to write any sort of C extension. --bb - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Need more comments from scientific community on python-dev
On 01/11/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: > And it may be a good idea to also have a get_ctype method or some-such > on the ctypes attribute so that one could get a "ctypes description" > from the NumPy data-type. It seems to me that at the python level, there's not much reason to choose the dtypes proposal over ctypes. There is one at the C level, it seems (though I, like perhaps most of the people on python-dev, have never actually tried using either). So perhaps, to persuade the python-dev folks, what is needed is a comparison of what has to be done at the C level. What would it take to rewrite numpy to use ctypes? There seems to be some problem with extending the type objects used by ctypes, but it's not very clear to me what that problem is (what the extensions are supposed to do). The argument that *some* datatypes format should become standard is much easier. A. M. Archibald - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Reading records from file and sorting
El dc 01 de 11 del 2006 a les 15:18 +, en/na George Sakkis va escriure: > > Why this is too specific or error-prone? > > Because it > 1. repeats the field types > 2. requires adding up the length of all previous fields as offset. > > If you're not convinced yet, try writing this in less than 3 seconds > ;-): > records = N.fromfile(a_file, dtype=N.dtype('i2,i4,f4,S5,B,Q')) > records_by_f5 = ?? Ah, I see your point :) > > I think your solution is quite good.If what you want is a more compact way > > to > > write the above, you can > > try with: > > > > In [56]:records=numpy.array([(1,1),(0,2)], dtype="i2,i4") > > In [57]:records[records['f0'].argsort()] > > Out[57]: > > array([(0, 2), (1, 1)], > > dtype=[('f0', ' > In [58]:records[records['f1'].argsort()] > > Out[58]: > > array([(1, 1), (0, 2)], > > dtype=[('f0', ' > Ah, much better; I didn't know you can index a normal array (not > recarray) by label. Now, if there's a way to do the sorting in place > (records.sort('f1') doesn't work unfortunately), that would be perfect. Yes, I agree that having the possibility to do records.sort('f1') would be a great addition (both in terms of usability but also efficiency). Cheers, -- Francesc Altet| Be careful about using the following code -- Carabos Coop. V. | I've only proven that it works, www.carabos.com | I haven't tested it. -- Donald Knuth - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Need more comments from scientific community on python-dev
Alexander Belopolsky wrote: > On 10/31/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: > ... > >> Please understand what I meant. I meant putting effort into getting >> PyArray_DescrConverter to allow ctypes inputs and convert to the >> appropriate PyArray_Descr * structure. I already understand ctypes >> objects. I want the dtype() command to also understand them. >> >> > > I think I am starting to understand. Forgive me for being slow. > And I think I'm beginning to understand why some people are resistant to what I'm saying. I have no problem converting from ctypes types to the underlying PyArray_Descr structure. I don't necessarily want that to be the only way to describe new types but I sure don't mind people using that approach. I suspect it's the concern about "how to describe data-formats on the Python level" that have people concerned. > Is it correct that you don't mind writing c_int * 10 instead of > dtype((' PyTypeObject at the C level? That is correct. > If this is the case, I would suggest to > merge ctypes syntax with your implementation. > This may help to make > the case for the python-dev crowd. Thanks for this suggestion. You could very probably be right. > I believe very few people > understand the subtle problems in inheriting from PyTypeObject and > resist your proposal simply because they like c_int * 10 better than > dtype((' > There is no reason why ctypes should be implemented the way it is. It > is not necessary that type(c_int()) is c_int. If a type with almost > the same properties gets into the core, ctypes developers may see an > advantage of simply inheriting from it and adding a factory __call__ > method. Meanwhile, users familiar with ctypes will not need to learn > yet another type specification syntax. > > It would actually be "easier" for NumPy to understand ctypes syntax if something like a data-type object were. As it is, the converter to a PyArray_Descr structure will probably have to check the tp_name of the ctypes. Maybe this will help with the PEP to describe the difficulty of using ctypes constructs inside of other programs. And it may be a good idea to also have a get_ctype method or some-such on the ctypes attribute so that one could get a "ctypes description" from the NumPy data-type. -Travis - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Need more comments from scientific community on python-dev
On 10/31/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: > > I'm recruiting more comments on python-dev regarding my two proposals > for improving Python's native ability to share ndarray-like information. > I believe there are another really important reason to support Travis's proposal. Python should have a general, simple, powerful and standard way to associate type metadata to binary streams. This enables efficient share or memory, but also can help a lot to achieve inter-language capabilities. As an example, I would to make some comments about MPI, the "de facto" standard for message-passing in parallel computing. When MPI specification was being developed, there were many different, incompatible libraries for message passing, and many of them (ie. PVM) usually communicated binary data following a pack/unpack approach. The MPI Forum decided to add an alternative approach, adding a class 'MPI_Datatype', and many predefined instances of this class (MPI_INT, MPI_FLOAT, etc.) in order to represent the basic datatypes (integers, floats, strings, complex numbers) in C, Fortran, and C++. Predefined MPI datatypes can be used as building blocks for describing very complicated memory layouts and derived,nested structures. This way, any implementations of this standard can support interprocess communication in a multi-language, muti-architecture approach. MPI datatypes can also be "decoded" in order to get the basic, predefined types contained in a user-defined datatype. I think the MPI example, despite being taken from a very specific domain with particular needs, has a strong connection with Travis's proposal. Pack/unpack degrades performance, but if you want to efficiently share binary data (with other languages/architecture), then a general and extensible mechanism for attaching type metadata to binary streams must me defined. I would like to know your opinions about this. Travis's datatypes in Python should be more that something to share data, they should be able to **describe** data. And I am not sure if ctypes can be be the way. Can Jython take advantage of ctypes??? Or in the near future CPython/Jython will have a 'jtypes' module? I forget! Travis/Pearu, why don't you develop a 'ftypes' for Fortran binary data, and next ask Python core developers to include it in standard library (a joke, of course)? Travis, if you think my previous example about MPI can help, I can resend this post to Python-Dev. I ask you this because I really want to help and not to make noise. Regars, -- Lisandro Dalcín --- Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC) Instituto de Desarrollo Tecnológico para la Industria Química (INTEC) Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET) PTLC - Güemes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594 - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Need more comments from scientific community on python-dev
On 10/31/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: > No, it's not that simple. We have a headache whenever we want to do > something like I just did and separate out the concepts of what makes a > Python Object a Python object. Now, we don't just modify a simple > C-structure (PyArray_Descr *), we have to modify a "meta-type" or a > altered dictionary and get that change put in to ctypes. I think I am starting to understand. Forgive me for being slow. Is it correct that you don't mind writing c_int * 10 instead of dtype(('http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Reading records from file and sorting
Francesc Altet wrote: > El dt 31 de 10 del 2006 a les 23:38 +, en/na George Sakkis va > escriure: > > Is there a more elegant and/or faster way to read some records from a > > file and then sort them by different fields ? What I have now is too > > specific and error-prone in general: > > > > import numpy as N > > records = N.fromfile(a_file, dtype=N.dtype('i2,i4')) > > records_by_f0 = records.take(records.getfield('i2').argsort()) > > records_by_f1 = records.take(records.getfield('i4',2).argsort()) > > > > If there's a better way, I'd like to see it; bonus points for in-place > > sorting. > > Why this is too specific or error-prone? Because it 1. repeats the field types 2. requires adding up the length of all previous fields as offset. If you're not convinced yet, try writing this in less than 3 seconds ;-): records = N.fromfile(a_file, dtype=N.dtype('i2,i4,f4,S5,B,Q')) records_by_f5 = ?? > I think your solution is quite good.If what you want is a more compact way to > write the above, you can > try with: > > In [56]:records=numpy.array([(1,1),(0,2)], dtype="i2,i4") > In [57]:records[records['f0'].argsort()] > Out[57]: > array([(0, 2), (1, 1)], > dtype=[('f0', ' In [58]:records[records['f1'].argsort()] > Out[58]: > array([(1, 1), (0, 2)], > dtype=[('f0', 'http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Need more comments from scientific community on python-dev
Grr, I wrote something up (it was wonderfully eloquent and convincing -- trust me!), but the gmane interface seems to have lost it (I posted two things before responding to the two "authorization requested" emails, and only one of the two things ever got posted it seems.) --bbOn 11/2/06, Lisandro Dalcin <[EMAIL PROTECTED]> wrote: On 10/31/06, Bill Baxter <[EMAIL PROTECTED]> wrote:> One thing I see with PIL and Matplotlib and PyOpenGL is that they're having> to add specific support for Numpy and numeric and numarray and PIL and > ctypes etc.This is a real problem, and a waste of developing time, because welack a **general** and **standard** mechanism.> would the proposed extensions make it> possible for all these different packages to just have to support "buffer > protocol" and magically be able to work with numpy or numeric without having> to introduce explicit dependencies and support code for all those other> packages?I think this is the actual reason of Travis's proposal, and of all other people like me supporting him.> If I've got the facts straight then I'd be happy to go and say> that on comp.lang.python.>Please, go on! - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Need more comments from scientific community on python-dev
On 10/31/06, Bill Baxter <[EMAIL PROTECTED]> wrote: > One thing I see with PIL and Matplotlib and PyOpenGL is that they're having > to add specific support for Numpy and numeric and numarray and PIL and > ctypes etc. This is a real problem, and a waste of developing time, because we lack a **general** and **standard** mechanism. > would the proposed extensions make it > possible for all these different packages to just have to support "buffer > protocol" and magically be able to work with numpy or numeric without having > to introduce explicit dependencies and support code for all those other > packages? I think this is the actual reason of Travis's proposal, and of all other people like me supporting him. > If I've got the facts straight then I'd be happy to go and say > that on comp.lang.python. > Please, go on! -- Lisandro Dalcín --- Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC) Instituto de Desarrollo Tecnológico para la Industria Química (INTEC) Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET) PTLC - Güemes 3450, (3000) Santa Fe, Argentina Tel/Fax: +54-(0)342-451.1594 - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Reading records from file and sorting
El dt 31 de 10 del 2006 a les 23:38 +, en/na George Sakkis va escriure: > Is there a more elegant and/or faster way to read some records from a > file and then sort them by different fields ? What I have now is too > specific and error-prone in general: > > import numpy as N > records = N.fromfile(a_file, dtype=N.dtype('i2,i4')) > records_by_f0 = records.take(records.getfield('i2').argsort()) > records_by_f1 = records.take(records.getfield('i4',2).argsort()) > > If there's a better way, I'd like to see it; bonus points for in-place > sorting. Why this is too specific or error-prone? I think your solution is quite good. If what you want is a more compact way to write the above, you can try with: In [56]:records=numpy.array([(1,1),(0,2)], dtype="i2,i4") In [57]:records[records['f0'].argsort()] Out[57]: array([(0, 2), (1, 1)], dtype=[('f0', 'http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] [SciPy-user] Need more comments from scientific community on python-dev
> "Travis" == Travis Oliphant <[EMAIL PROTECTED]> writes: Travis> 2) Examples of sharing memory between two objects. PIL is Travis> the classic example and has some merit, but because the Travis> internal memory layout of the PIL is 'pointer-to-pointers' Travis> instead of 'big-chunk-of-memory' it's not a 1-1 match to Travis> NumPy and the array interface only can comunicate Travis> information about the "mode." But, I can see other Travis> examples. PyMedia, PyGame, PyVideo? CVXOPT, PyVoxel. VTK-Python and TVTK use this. Right now these use the buffer protocol to allow users to pass numpy data into a vtkDataArray. It works reasonably well. The VTK data arrays have type information so it is not absolutely essential for an extended buffer protocol here. TVTK uses this underlying functionality in VTK to present a cleaner interface. The idea is to have VTK use the data setup and manipulated by numpy without an expensive copy. The only caveat is that you need to hang on to a reference of the numpy array if not you will end up with a segfault. I just thought this might be a useful data point. FWIW, I am all for ndarrays/extended buffers in Python core. It would encourage a standard way to pass data in and out of wrapped code. cheers, prabhu - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion