Movatterモバイル変換


[0]ホーム

URL:


SciPy

numpy.seterrobj

numpy.seterrobj(errobj)

Set the object that defines floating-point error handling.

The error object contains all information that defines the error handlingbehavior in NumPy.seterrobj is used internally by the otherfunctions that set error handling behavior (seterr,seterrcall).

Parameters:

errobj : list

The error object, a list containing three elements:[internal numpy buffer size, error mask, error callback function].

The error mask is a single integer that holds the treatment informationon all four floating point errors. The information for each error typeis contained in three bits of the integer. If we print it in base 8, wecan see what treatment is set for “invalid”, “under”, “over”, and“divide” (in that order). The printed string can be interpreted with

  • 0 : ‘ignore’
  • 1 : ‘warn’
  • 2 : ‘raise’
  • 3 : ‘call’
  • 4 : ‘print’
  • 5 : ‘log’

Notes

For complete documentation of the types of floating-point exceptions andtreatment options, seeseterr.

Examples

>>>old_errobj=np.geterrobj()# first get the defaults>>>old_errobj[10000, 0, None]
>>>deferr_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()iserr_handlerTrue

Previous topic

numpy.errstate

Next topic

numpy.geterrobj

  • © Copyright 2008-2009, The Scipy community.
  • Last updated on Jun 10, 2017.
  • Created usingSphinx 1.5.3.

[8]ページ先頭

©2009-2025 Movatter.jp