On Tue, Sep 29, 2009 at 11:00 AM, Neal Becker <ndbeck...@gmail.com> 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 [13]: obj
> Out[13]: fixed_pt_array([  0,  32,  64,  96, 128])
>
> In [14]: obj*100 < this should overflow
> enter: [  0  32  64  96 128] << on entry into __array_wrap
> enter: [0 32 64 96 128]
> exit: [  0  32  64  96 128]
> Out[14]: fixed_pt_array([    0,  3200,  6400,  9600, 12800])
>
> Apparantly, obj*100 is never passed to array_wrap.
>
> Is there another way I can do this?
>
> I believe array wrap has to be explicitly called after the fact. The
problem is that you derived from ndarray, but fixed point isn't an ndarray
because ndarray doesn't *have* fixed point. If you were to implement *using*
ndarray you could catch everything in the operator calls. As a rule of
thumb, inheritance is always the wrong thing to do ;)

Chuck
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to