[Numpy-discussion] ieeespecial

Todd Miller jmiller at stsci.edu
Mon Oct 11 04:28:51 EDT 2004


On Sun, 2004-10-10 at 21:03, Darren Dale wrote:
> On Sunday 10 October 2004 08:29 pm, you wrote:
> > On Sun, 2004-10-10 at 15:47, Darren Dale wrote:
> > > Hello,
> > >
> > > I am getting invalid numeric result exceptions when dividing a complex
> > > array by zero. Is this the desired behavior?
> >
> >
> > This is what I would have expected,  and examining the definition I have
> > for complex division in numarray/Include/numarray/numcomplex.h,  I don't
> > see a problem.   The definition should probably be checked by an extra
> > set of eyes.  Looks OK to me.
> 
> Hi Todd,
> 
> Sorry, I wasn't clear. I was wondering if it should raise a divide by zero 
> exception and return an inf, as the real data types do, instead of an invalid 
> numeric result and a nan.  As it stands now, we have to handle divide by zero 
> differently for different data types, if we need to filter/replace such 
> values.

Numarray's error handling system is pretty flexible, and can raise
exceptions on divide by zero if configured properly, or can ignore them
altogether.  See section 4.9 in the numarray-1.1 manual here:

http://prdownloads.sourceforge.net/numpy/numarray-1.1.pdf?download

It's an interesting question regarding the inf vs. nan.   Looking at the
complex division macro (NUM_CDIV) in numcomplex.h,  I don't understand
why we're getting nans now and not infs;  it might be a bug in the
macro,  but I don't see it.

Regards,
Todd





More information about the NumPy-Discussion mailing list