Re: [Numpy-discussion] __array_wrap__

2009-09-29 Thread Pauli Virtanen
Tue, 29 Sep 2009 14:55:44 -0400, Neal Becker wrote: > This seems to work now, but I'm wondering if Charles is correct, that > inheritance isn't such a great idea here. > > The advantage of inheritance is I don't have to implement forwarding all > the functions, a pretty big advantage. (I wonder i

Re: [Numpy-discussion] Convert data into rectangular grid

2009-09-29 Thread David Huard
On Mon, Sep 28, 2009 at 8:45 PM, jah wrote: > On Mon, Sep 28, 2009 at 4:48 PM, wrote: > >> On Mon, Sep 28, 2009 at 7:19 PM, jah wrote: >> > Hi, >> > >> > Suppose I have a set of x,y,c data (something useful for >> > matplotlib.pyplot.plot() ). Generally, this data is not rectangular at >> > al

Re: [Numpy-discussion] fixed_pt prototype using aggregation

2009-09-29 Thread Charles R Harris
On Tue, Sep 29, 2009 at 4:50 PM, Neal Becker wrote: > I have a prototype for fixed_pt without using inheritance. I think I like > it. Any thoughts? > > There is a line 177 characters long ;) Looks like a step in the right direction, though. If you add the various operations of interest -- mul,

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Christopher Barker
josef.p...@gmail.com wrote: > WindowsXP: > > Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit > (Intel)] on win32 struct.pack('>d', -0.0) > '\x80\x00\x00\x00\x00\x00\x00\x00' struct.pack(' '\x00\x00\x00\x00\x00\x00\x00\x80' > > Python 2.4.3 (#69, Mar 29 2006, 17:35:34

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread josef . pktd
On Tue, Sep 29, 2009 at 6:48 PM, Christopher Barker wrote: >>> I'm assuming it's a bug that was fixed somewhere in between? > > It works on my 2.5, on a PPC: > > In [10]: struct.pack('>d', -0.0) > Out[10]: '\x80\x00\x00\x00\x00\x00\x00\x00' > > In [11]: struct.pack(' Out[11]: '\x00\x00\x00\x00\x00

[Numpy-discussion] fixed_pt prototype using aggregation

2009-09-29 Thread Neal Becker
I have a prototype for fixed_pt without using inheritance. I think I like it. Any thoughts? import numpy as np def rnd (x, frac_bits, _max): "A rounding policy" x1 = x >> (frac_bits-1) if (x1 == _max): return x1 >> 1 else: return (x1+1) >> 1 def shift_l

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Christopher Barker
>> I'm assuming it's a bug that was fixed somewhere in between? It works on my 2.5, on a PPC: In [10]: struct.pack('>d', -0.0) Out[10]: '\x80\x00\x00\x00\x00\x00\x00\x00' In [11]: struct.pack('>> struct.pack('>d', -0.0) '\x00\x00\x00\x00\x00\x00\x00\x00' >>> struct.pack('http://mail.scipy.org/m

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Robert Kern
On Tue, Sep 29, 2009 at 16:49, Joe Kington wrote: > Using 'd' rather than 'f' doesn't fix the problem... > > Python 2.3.4 (#1, Jan  9 2007, 16:40:09) > [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. import struct

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Joe Kington
Using 'd' rather than 'f' doesn't fix the problem... Python 2.3.4 (#1, Jan 9 2007, 16:40:09) [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import struct >>> struct.pack('d', -0.0) '\x00\x00\x00\x00\x00\x00\x00\x80' <-

Re: [Numpy-discussion] chebyshev module

2009-09-29 Thread Robert Kern
On Tue, Sep 29, 2009 at 16:40, Charles R Harris wrote: > Oh, and is it advisable to have a __copy__ (or copy) method? Implement __getstate__ and __setstate__. Both the pickle module and the copy module will use those functions. -- Robert Kern "I have come to believe that the whole world is an

[Numpy-discussion] chebyshev module

2009-09-29 Thread Charles R Harris
Hi all, I'm at the polishing stage on this module and at this point would like some input on the names. Yeah, a bit late ;) As it stands the module emulates the polynomial module in most things with the substitution of cheb for poly and the poly1d equivalent is Cheb1d. There are also a few deviati

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Robert Kern
On Tue, Sep 29, 2009 at 16:37, Joe Kington wrote: > I know it's a bit pointless profiling these, but just so I can avoid doing > real work for a bit... > > In [1]: import sys, struct, math > > In [2]: def comp_struct(x): >    ...: # Get the first or last byte, depending on endianness >    ...:

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Joe Kington
I know it's a bit pointless profiling these, but just so I can avoid doing real work for a bit... In [1]: import sys, struct, math In [2]: def comp_struct(x): ...: # Get the first or last byte, depending on endianness ...: # (using '>f' or ' 0: return False : elif x < 0:

Re: [Numpy-discussion] Question about improving genfromtxt errors

2009-09-29 Thread Christopher Barker
Pierre GM wrote: >> How does it handle the wrong number of tokens now? if an exception is >> raised somewhere, then that's the only place you'd need to anything >> extra anyway. > > It silently fails outside the loop, when the list of splitted rows is > converted into an array: if one row has a

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Christopher Barker
Christian Heimes wrote: > How about using atan2()? :) unless atan2 shortcuts for the easy ones, that doesn't strike me as efficient (though with python function call overhead, maybe!). Anyway, of course, some googling that I should have done in the first place, revealed "double.py", from Martin

Re: [Numpy-discussion] max value of np scalars

2009-09-29 Thread Charles R Harris
On Tue, Sep 29, 2009 at 2:52 PM, Neal Becker wrote: > I need the max value of an np scalar type. I had used this code: > > def get_max(is_signed, base_type, total_bits): >print 'get_max:', is_signed, base_type, total_bits >if is_signed: >return (~(base_type(-1) << (total_bits-1))

Re: [Numpy-discussion] max value of np scalars

2009-09-29 Thread Robert Kern
On Tue, Sep 29, 2009 at 15:52, Neal Becker wrote: > I need the max value of an np scalar type.  I had used this code: > > def get_max(is_signed, base_type, total_bits): >    print 'get_max:', is_signed, base_type, total_bits >    if is_signed: >        return (~(base_type(-1) << (total_bits-1))) >

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Christian Heimes
Christopher Barker wrote: > Hi folks, > > This isn't really a numpy question, and I'm doing this with regular old > python, but I figure you are the folks that would know this: > > How do I get python to make a distinction between -0.0 and 0.0? IN this > case, I'm starting with user input, so:

[Numpy-discussion] max value of np scalars

2009-09-29 Thread Neal Becker
I need the max value of an np scalar type. I had used this code: def get_max(is_signed, base_type, total_bits): print 'get_max:', is_signed, base_type, total_bits if is_signed: return (~(base_type(-1) << (total_bits-1))) else: print type(base_type (-1) << total_bits)

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Robert Kern
On Tue, Sep 29, 2009 at 15:34, Christopher Barker wrote: > Joe Kington wrote: >> I just realized that what I'm doing won't work on older versions of >> python, anyway... > > What I was looking for was which actual bit the sign bit is, as > expressed as a native integer, so I can do a bitwise_and.

Re: [Numpy-discussion] Another dumb structured array question

2009-09-29 Thread Robert Kern
On Tue, Sep 29, 2009 at 15:32, David Warde-Farley wrote: > Is there an easy way to get multiple subdtypes out? e.g. if I have a > dtype > > dtype([('foo', 'i4'), ('bar', 'i8'), ('baz', 'S100')]) > > and an array with that dtype, is there a way to only get the 'foo' and > 'bar'? > > arr[('foo','bar

Re: [Numpy-discussion] Question about improving genfromtxt errors

2009-09-29 Thread Bruce Southey
On 09/29/2009 01:30 PM, Pierre GM wrote: On Sep 29, 2009, at 1:57 PM, Bruce Southey wrote: On 09/29/2009 11:37 AM, Christopher Barker wrote: Pierre GM wrote: Probably more than memory is the execution time involved in printing these problem rows. The rows with prob

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Christopher Barker
Joe Kington wrote: > I just realized that what I'm doing won't work on older versions of > python, anyway... What I was looking for was which actual bit the sign bit is, as expressed as a native integer, so I can do a bitwise_and. But now that I think about it, I only need to test zero, not all

[Numpy-discussion] Another dumb structured array question

2009-09-29 Thread David Warde-Farley
Is there an easy way to get multiple subdtypes out? e.g. if I have a dtype dtype([('foo', 'i4'), ('bar', 'i8'), ('baz', 'S100')]) and an array with that dtype, is there a way to only get the 'foo' and 'bar'? arr[('foo','bar')] doesn't seem to work. David

Re: [Numpy-discussion] [SciPy-dev] Deprecate chararray [was Plea for help]

2009-09-29 Thread David Goldsmith
On Tue, Sep 29, 2009 at 10:55 AM, Michael Droettboom wrote: > 2) Improve documentation > > Every method now has a docstring, and a new page of routines has been > added to the Sphinx tree. > > Um, where did you do this, 'cause it's not showing up in the doc wiki. DG __

Re: [Numpy-discussion] Question about improving genfromtxt errors

2009-09-29 Thread Pierre GM
On Sep 29, 2009, at 3:28 PM, Christopher Barker wrote: > > well, how does one test compare to: > > read the line from the file > split the line into tokens > parse each token > > I can't imagine it's significant, but I guess you only know with > profiling. That's on the parsing part. I'd like

Re: [Numpy-discussion] Question about improving genfromtxt errors

2009-09-29 Thread Christopher Barker
Pierre GM wrote: >> Another idea: only store the indexes of the rows that have the "wrong" >> number of columns -- if that's a large number, then then user has >> bigger >> problems than memory usage! > > That was my first idea, but then it adds tests in the inside loop > (which is what I'm tr

Re: [Numpy-discussion] __array_wrap__

2009-09-29 Thread Charles R Harris
On Tue, Sep 29, 2009 at 1:12 PM, Robert Kern wrote: > On Tue, Sep 29, 2009 at 14:08, Charles R Harris > wrote: > > > > > > On Tue, Sep 29, 2009 at 12:48 PM, Robert Kern > wrote: > >> > >> On Tue, Sep 29, 2009 at 13:35, Charles R Harris > >> wrote: > >> > > >> > On Tue, Sep 29, 2009 at 12:23 PM

Re: [Numpy-discussion] __array_wrap__

2009-09-29 Thread Robert Kern
On Tue, Sep 29, 2009 at 14:08, Charles R Harris wrote: > > > On Tue, Sep 29, 2009 at 12:48 PM, Robert Kern wrote: >> >> On Tue, Sep 29, 2009 at 13:35, Charles R Harris >> wrote: >> > >> > On Tue, Sep 29, 2009 at 12:23 PM, Robert Kern >> > wrote: >> >> >> >> On Tue, Sep 29, 2009 at 13:09, Charle

Re: [Numpy-discussion] __array_wrap__

2009-09-29 Thread Charles R Harris
On Tue, Sep 29, 2009 at 12:48 PM, Robert Kern wrote: > On Tue, Sep 29, 2009 at 13:35, Charles R Harris > wrote: > > > > On Tue, Sep 29, 2009 at 12:23 PM, Robert Kern > wrote: > >> > >> On Tue, Sep 29, 2009 at 13:09, Charles R Harris > >> wrote: > >> > > >> > > >> > On Tue, Sep 29, 2009 at 11:0

Re: [Numpy-discussion] __array_wrap__

2009-09-29 Thread Charles R Harris
On Tue, Sep 29, 2009 at 12:55 PM, Neal Becker wrote: > This seems to work now, but I'm wondering if Charles is correct, that > inheritance isn't such a great idea here. > > The advantage of inheritance is I don't have to implement forwarding all > the > functions, a pretty big advantage. (I wonde

Re: [Numpy-discussion] where does numpy get its pow function?

2009-09-29 Thread David Goldsmith
On Tue, Sep 29, 2009 at 11:50 AM, Robert Kern wrote: > When given two specific options, I only say "yes" or "no" when I want > to be annoying. > > Hey, Robert, didn't you want to put emphasis markers around "want"? ;-) Annoyingly yours, DG ___ NumPy-D

Re: [Numpy-discussion] __array_wrap__

2009-09-29 Thread Neal Becker
This seems to work now, but I'm wondering if Charles is correct, that inheritance isn't such a great idea here. The advantage of inheritance is I don't have to implement forwarding all the functions, a pretty big advantage. (I wonder if there is some way to do some of these as a generic 'mixin'

Re: [Numpy-discussion] subclassing

2009-09-29 Thread Keith Goodman
On Tue, Sep 29, 2009 at 11:25 AM, Robert Kern wrote: > On Tue, Sep 29, 2009 at 13:19, Keith Goodman wrote: >> I ran across a problem while using numpy. But the problem is more of >> python problem. I hope I am not too far off topic. >> >> I have a class and a subclass: >> >> class myclass: >> >>

Re: [Numpy-discussion] [SciPy-dev] Deprecate chararray [was Plea for help]

2009-09-29 Thread David Goldsmith
Michael: Thanks so much, this is genuinely awesome! Don't forget to email Joe Harrington for your T-shirt - you more than deserve it! ;-) A few specific comments below On Tue, Sep 29, 2009 at 10:55 AM, Michael Droettboom wrote: > I now have a rather large patch ready which addresses the follow

Re: [Numpy-discussion] where does numpy get its pow function?

2009-09-29 Thread Robert Kern
On Tue, Sep 29, 2009 at 13:31, Lou Pecora wrote: > - Original Message > From: Robert Kern > To: Discussion of Numerical Python > Sent: Tuesday, September 29, 2009 12:54:46 PM > Subject: Re: [Numpy-discussion] where does numpy get its pow function? > > On Tue, Sep 29, 2009 at 11:47, Chri

Re: [Numpy-discussion] __array_wrap__

2009-09-29 Thread Robert Kern
On Tue, Sep 29, 2009 at 13:35, Charles R Harris wrote: > > On Tue, Sep 29, 2009 at 12:23 PM, Robert Kern wrote: >> >> On Tue, Sep 29, 2009 at 13:09, Charles R Harris >> wrote: >> > >> > >> > On Tue, Sep 29, 2009 at 11:00 AM, Neal Becker >> > wrote: >> >> >> >> fixed_pt arrays need to apply the

Re: [Numpy-discussion] __array_wrap__

2009-09-29 Thread Charles R Harris
On Tue, Sep 29, 2009 at 12:23 PM, Robert Kern wrote: > On Tue, Sep 29, 2009 at 13:09, Charles R Harris > wrote: > > > > > > On Tue, Sep 29, 2009 at 11:00 AM, Neal Becker > wrote: > >> > >> fixed_pt arrays need to apply the overflow_policy after operations > >> (overflow_policy could be clip, or

Re: [Numpy-discussion] __array_wrap__

2009-09-29 Thread Charles R Harris
On Tue, Sep 29, 2009 at 12:35 PM, Charles R Harris < charlesr.har...@gmail.com> wrote: > > > On Tue, Sep 29, 2009 at 12:23 PM, Robert Kern wrote: > >> On Tue, Sep 29, 2009 at 13:09, Charles R Harris >> wrote: >> > >> > >> > On Tue, Sep 29, 2009 at 11:00 AM, Neal Becker >> wrote: >> >> >> >> fixe

Re: [Numpy-discussion] where does numpy get its pow function?

2009-09-29 Thread Lou Pecora
- Original Message From: Robert Kern To: Discussion of Numerical Python Sent: Tuesday, September 29, 2009 12:54:46 PM Subject: Re: [Numpy-discussion] where does numpy get its pow function? On Tue, Sep 29, 2009 at 11:47, Chris Colbert wrote: > Does numpy use pow from math.h or something

Re: [Numpy-discussion] subclassing

2009-09-29 Thread Robert Kern
On Tue, Sep 29, 2009 at 13:19, Keith Goodman wrote: > I ran across a problem while using numpy. But the problem is more of > python problem. I hope I am not too far off topic. > > I have a class and a subclass: > > class myclass: > >    def __init__(self, x): >        self.x = x > >    def __getit

Re: [Numpy-discussion] Question about improving genfromtxt errors

2009-09-29 Thread Pierre GM
On Sep 29, 2009, at 1:57 PM, Bruce Southey wrote: > On 09/29/2009 11:37 AM, Christopher Barker wrote: >> Pierre GM wrote: >> > Probably more than memory is the execution time involved in printing > these problem rows. The rows with problems will be printed outside the loop (with at least an a

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Joe Kington
I just realized that what I'm doing won't work on older versions of python, anyway... Things work fine on 2.6 Python 2.6.2 (r262:71600, Sep 3 2009, 09:36:43) [GCC 3.4.6 20060404 (Red Hat 3.4.6-9)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import struct

Re: [Numpy-discussion] __array_wrap__

2009-09-29 Thread Robert Kern
On Tue, Sep 29, 2009 at 13:09, Charles R Harris wrote: > > > On Tue, Sep 29, 2009 at 11:00 AM, Neal Becker wrote: >> >> fixed_pt arrays need to apply the overflow_policy after operations >> (overflow_policy could be clip, or throw exception). >> >> I thought __array_wrap__ would work for this, bu

[Numpy-discussion] subclassing

2009-09-29 Thread Keith Goodman
I ran across a problem while using numpy. But the problem is more of python problem. I hope I am not too far off topic. I have a class and a subclass: class myclass: def __init__(self, x): self.x = x def __getitem__(self, index): if type(index) is slice: x =

Re: [Numpy-discussion] [SciPy-dev] Deprecate chararray [was Plea for help]

2009-09-29 Thread Charles R Harris
On Tue, Sep 29, 2009 at 11:55 AM, Michael Droettboom wrote: > I now have a rather large patch ready which addresses the following > issues with chararrays. Would it be possible to get SVN commit > priviledges, or would you prefer a patch file? > > If you are going to maintain this part of numpy,

Re: [Numpy-discussion] where does numpy get its pow function?

2009-09-29 Thread Chris Colbert
my powers are typically doubles I traced the problem down to the pow function in math.h just being slow... Thanks! On Tue, Sep 29, 2009 at 7:53 PM, Charles R Harris wrote: > > > On Tue, Sep 29, 2009 at 11:01 AM, Chris Colbert wrote: >> >> are there any particular optimization flags issued when

Re: [Numpy-discussion] __array_wrap__

2009-09-29 Thread Charles R Harris
On Tue, Sep 29, 2009 at 11:00 AM, Neal Becker wrote: > fixed_pt arrays need to apply the overflow_policy after operations > (overflow_policy could be clip, or throw exception). > > I thought __array_wrap__ would work for this, but it seems to not be called > when I need it. For example: > > In [

Re: [Numpy-discussion] Question about improving genfromtxt errors

2009-09-29 Thread Bruce Southey
On 09/29/2009 11:37 AM, Christopher Barker wrote: > Pierre GM wrote: > >> I was thinking about something this week-end: we could create a second >> list when looping on the rows, where we would store the length of each >> splitted row. After the loop, we can find if these values don't match >>

Re: [Numpy-discussion] [SciPy-dev] Deprecate chararray [was Plea for help]

2009-09-29 Thread Michael Droettboom
I now have a rather large patch ready which addresses the following issues with chararrays. Would it be possible to get SVN commit priviledges, or would you prefer a patch file? 1) Fix bugs in Trac http://projects.scipy.org/numpy/ticket/1199 (chararray.expandtabs broken) http://projects.scipy.

Re: [Numpy-discussion] where does numpy get its pow function?

2009-09-29 Thread Charles R Harris
On Tue, Sep 29, 2009 at 11:01 AM, Chris Colbert wrote: > are there any particular optimization flags issued when building numpy > aside from the following? > > -fwrapv -O2 > > Numpy optimizes small integer powers using multiplication. What sort of numbers are you looking at? Chuck

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Charles R Harris
On Tue, Sep 29, 2009 at 10:53 AM, Christopher Barker wrote: > Hi folks, > > This isn't really a numpy question, and I'm doing this with regular old > python, but I figure you are the folks that would know this: > > How do I get python to make a distinction between -0.0 and 0.0? IN this > case, I'm

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Xavier Saint-Mleux
Christopher Barker wrote: > Pauli Virtanen wrote: > >> Tue, 29 Sep 2009 09:53:40 -0700, Christopher Barker wrote: >> [clip] >> >>> How can I identify -0.0? >>> >> signbit >> >> > > perfect for numpy, but at this point I don't have a numpy dependency > (very unusual for my code!

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Joe Kington
Well, this is messy, and nearly unreadable, but it should work and is pure python(and I think even be endian-independent). struct.unpack('b',struct.pack('>d', X)[0])[0] >= 0 (where X is the variable you want to test) In [54]: struct.unpack('b',struct.pack('>d',0.0)[0])[0] >= 0 Out[54]: True In [

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Bruce Southey
On 09/29/2009 12:08 PM, Gökhan Sever wrote: On Tue, Sep 29, 2009 at 11:53 AM, Christopher Barker mailto:chris.bar...@noaa.gov>> wrote: Hi folks, This isn't really a numpy question, and I'm doing this with regular old python, but I figure you are the folks that would know thi

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Christopher Barker
Pauli Virtanen wrote: > Tue, 29 Sep 2009 09:53:40 -0700, Christopher Barker wrote: > [clip] >> How can I identify -0.0? > > signbit > perfect for numpy, but at this point I don't have a numpy dependency (very unusual for my code!). Anyone know a pure-python way to get it? It seems I should be

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Gökhan Sever
On Tue, Sep 29, 2009 at 11:53 AM, Christopher Barker wrote: > Hi folks, > > This isn't really a numpy question, and I'm doing this with regular old > python, but I figure you are the folks that would know this: > > How do I get python to make a distinction between -0.0 and 0.0? IN this > case, I'm

Re: [Numpy-discussion] Question about improving genfromtxt errors

2009-09-29 Thread Pierre GM
On Sep 29, 2009, at 12:37 PM, Christopher Barker wrote: > Pierre GM wrote: > Another idea: only store the indexes of the rows that have the "wrong" > number of columns -- if that's a large number, then then user has > bigger > problems than memory usage! That was my first idea, but then it add

Re: [Numpy-discussion] where does numpy get its pow function?

2009-09-29 Thread Chris Colbert
are there any particular optimization flags issued when building numpy aside from the following? -fwrapv -O2 On Tue, Sep 29, 2009 at 6:54 PM, Robert Kern wrote: > On Tue, Sep 29, 2009 at 11:47, Chris Colbert wrote: >> Does numpy use pow from math.h or something else? > > Yes. > > -- > Robert

[Numpy-discussion] __array_wrap__

2009-09-29 Thread Neal Becker
fixed_pt arrays need to apply the overflow_policy after operations (overflow_policy could be clip, or throw exception). I thought __array_wrap__ would work for this, but it seems to not be called when I need it. For example: In [13]: obj Out[13]: fixed_pt_array([ 0, 32, 64, 96, 128]) In [

Re: [Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Pauli Virtanen
Tue, 29 Sep 2009 09:53:40 -0700, Christopher Barker wrote: [clip] > How can I identify -0.0? signbit -- Pauli Virtanen ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] where does numpy get its pow function?

2009-09-29 Thread Robert Kern
On Tue, Sep 29, 2009 at 11:47, Chris Colbert wrote: > Does numpy use pow from math.h or something else? Yes. -- 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 t

[Numpy-discussion] making the distinction between -0.0 and 0.0..

2009-09-29 Thread Christopher Barker
Hi folks, This isn't really a numpy question, and I'm doing this with regular old python, but I figure you are the folks that would know this: How do I get python to make a distinction between -0.0 and 0.0? IN this case, I'm starting with user input, so: In [3]: float("-0.0") Out[3]: -0.0 so

[Numpy-discussion] where does numpy get its pow function?

2009-09-29 Thread Chris Colbert
Does numpy use pow from math.h or something else? I seem to be having a problem with slow pow under gcc when building an extension, but it's not affecting numpy. So if numpy uses that, then there is something else i'm missing. Cheers! Chris ___ NumPy-D

Re: [Numpy-discussion] Question about improving genfromtxt errors

2009-09-29 Thread Christopher Barker
Pierre GM wrote: > I was thinking about something this week-end: we could create a second > list when looping on the rows, where we would store the length of each > splitted row. After the loop, we can find if these values don't match > the expected number of columns `nbcols` and where. Then,

Re: [Numpy-discussion] fixed_pt some progress and a question

2009-09-29 Thread Robert Kern
On Tue, Sep 29, 2009 at 10:10, Neal Becker wrote: > I could force an additional conversion using np.array (xxx, dtype=float). > Seems wasteful. np.asarray() will not be wasteful. > The bigger question I have is, if I've subclassed an array, how can I get at > the underlying array type? x.view(

Re: [Numpy-discussion] fixed_pt some progress and a question

2009-09-29 Thread Neal Becker
josef.p...@gmail.com wrote: > On Tue, Sep 29, 2009 at 10:22 AM, Neal Becker wrote: >> This doesn't work either: >> >> def as_double (self): >> import math >> def _as_double_1 (x): >> return math.ldexp (x, -self.frac_bits) >> vecfunc = np.vectorize (_as_double_1, otypes=[np.float]) >> return vecfu

Re: [Numpy-discussion] fixed_pt some progress and a question

2009-09-29 Thread josef . pktd
On Tue, Sep 29, 2009 at 10:22 AM, Neal Becker wrote: > This doesn't work either: > >    def as_double (self): >        import math >        def _as_double_1 (x): >            return math.ldexp (x, -self.frac_bits) >        vecfunc = np.vectorize (_as_double_1, otypes=[np.float]) >        return ve

Re: [Numpy-discussion] fixed_pt some progress and a question

2009-09-29 Thread Neal Becker
This doesn't work either: def as_double (self): import math def _as_double_1 (x): return math.ldexp (x, -self.frac_bits) vecfunc = np.vectorize (_as_double_1, otypes=[np.float]) return vecfunc (self) In [49]: obj.as_double() Out[49]: fixed_pt_array(

[Numpy-discussion] fixed_pt some progress and a question

2009-09-29 Thread Neal Becker
I'm starting with a pure python implementation and have some progress. AFAICT, the only approach is to subclass ndarray and add the properties and behaviors I need. I ran into one issue though. In my function 'as_double', I need to get to the underlying 'int' array to pass to ldexp. I tried

Re: [Numpy-discussion] The problem with zero dimesnsional array

2009-09-29 Thread Fabrice Silva
Le mardi 29 septembre 2009 à 02:32 +0530, yogesh karpate a écrit : > Dear All, >I'm facing a bog problem in following . the code > snippet is as follows > % Compute the area > indicator### > for kT in range(leftbound,rightboun

Re: [Numpy-discussion] numpy.numarray.transpose()

2009-09-29 Thread Pauli Virtanen
Tue, 29 Sep 2009 11:08:42 +0200, Michael.Walker wrote: [clip] > I am referring to the behaviour of numpy.numarray.transpose() being that > of numpy.transpose() instead of numarray.transpose. One expects that You probably mean the transpose methods numpy.numarray.ndarray.transpose and numarray.nda

Re: [Numpy-discussion] numpy.numarray.transpose()

2009-09-29 Thread Michael . Walker
> On 09/28/2009 03:15 AM, Pauli Virtanen wrote: >> Mon, 28 Sep 2009 10:07:47 +0200, Michael.Walker wrote: >> [clip] >> >>> In [7]: f = f.transpose() >>> >>> In [8]: print f >>> [[1 3] >>> [2 4]] >>> >>> as expected. I mention this because I think that it is worth knowing >>> having lost a LOT o