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