15.12.2012 Views

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

scipy tutorial - Baustatik-Info-Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

SciPy Reference Guide, Release 0.8.dev<br />

errprint()<br />

errprint({flag}) sets the error printing flag for special functions (from the cephesmodule). The output is the<br />

previous state. With errprint(0) no error messages are shown; the default is errprint(1). If no argument is given<br />

the current state of the flag is returned and no change occurs.<br />

class errstate(**kwargs)<br />

Context manager for floating-point error handling.<br />

Using an instance of errstate as a context manager allows statements in that context to execute with a known<br />

error handling behavior. Upon entering the context the error handling is set with seterr and seterrcall, and upon<br />

exiting it is reset to what it was before.<br />

See Also:<br />

Parameters<br />

kwargs : {divide, over, under, invalid}<br />

Keyword arguments. The valid keywords are the possible floating-point exceptions.<br />

Each keyword should have a string value that defines the treatment for the particular<br />

error. Possible values are {‘ignore’, ‘warn’, ‘raise’, ‘call’, ‘print’, ‘log’}.<br />

seterr, geterr, seterrcall, geterrcall<br />

Notes<br />

The with statement was introduced in Python 2.5, and can only be used there by importing it: from<br />

__future__ import with_statement. In earlier Python versions the with statement is not available.<br />

For complete documentation of the types of floating-point exceptions and treatment options, see seterr.<br />

Examples<br />

>>> from __future__ import with_statement # use ’with’ in Python 2.5<br />

>>> olderr = np.seterr(all=’ignore’) # Set error handling to known state.<br />

>>> np.arange(3) / 0.<br />

array([ NaN, Inf, Inf])<br />

>>> with np.errstate(divide=’warn’):<br />

... np.arange(3) / 0.<br />

...<br />

__main__:2: RuntimeWarning: divide by zero encountered in divide<br />

array([ NaN, Inf, Inf])<br />

>>> np.sqrt(-1)<br />

nan<br />

>>> with np.errstate(invalid=’raise’):<br />

... np.sqrt(-1)<br />

...<br />

Traceback (most recent call last):<br />

File "", line 2, in <br />

FloatingPointError: invalid value encountered in sqrt<br />

Outside the context the error handling behavior has not changed:<br />

>>> np.geterr()<br />

{’over’: ’ignore’, ’divide’: ’ignore’, ’invalid’: ’ignore’,<br />

’under’: ’ignore’}<br />

3.17. Special functions (<strong>scipy</strong>.special) 423

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!