[Numpy-discussion] numarray: how to make sinc(x) function - "divide by zero" !

Sebastian Haase haase at msg.ucsf.edu
Mon Dec 5 14:35:00 CST 2005


Hi,
The best I could come up with was:

def sinc(r):
    na.Error.pushMode(all="ignore")
    a = na.where(r, na.divide(na.sin(r),r), 1)
    na.Error.popMode()
    return a

but I still seem to get  a warning...
>>> F.sinc(0)
Warning: Encountered invalid numeric result(s)  in divide
1.0

Thanks,
Sebastian Haase




More information about the Numpy-discussion mailing list