Set the object that defines floating-point error handling.
The error object contains all information that defines the error handling behavior in Numpy. seterrobj is used internally by the other functions that set error handling behavior (seterr, seterrcall).
Parameters : | errobj : list
|
---|
See also
geterrobj, seterr, geterr, seterrcall, geterrcall, getbufsize, setbufsize
Notes
For complete documentation of the types of floating-point exceptions and treatment options, see seterr.
Examples
>>> old_errobj = np.geterrobj() # first get the defaults
>>> old_errobj
[10000, 0, None]
>>> def err_handler(type, flag):
... print "Floating point error (%s), with flag %s" % (type, flag)
...
>>> new_errobj = [20000, 12, err_handler]
>>> np.seterrobj(new_errobj)
>>> np.base_repr(12, 8) # int for divide=4 ('print') and over=1 ('warn')
'14'
>>> np.geterr()
{'over': 'warn', 'divide': 'print', 'invalid': 'ignore', 'under': 'ignore'}
>>> np.geterrcall() is err_handler
True