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
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
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,
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
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
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
>> 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
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
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' <-
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
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
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
> ...:
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:
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
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
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))
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)))
>
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:
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)
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.
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
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
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
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
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
__
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
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
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
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
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
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
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
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'
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:
>>
>>
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
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
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
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
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
- 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
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
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
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
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
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 =
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,
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
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 [
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
>>
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.
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
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
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!
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 [
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
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
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
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
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
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 [
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
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
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
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
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,
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(
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
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
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(
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
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
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
> 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
73 matches
Mail list logo