Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Machine Learning
avec Scikit-Learn
Voir le programme détaillé
Module « numpy.matlib »

Classe « errstate »

Informations générales

Héritage

builtins.object
    errstate

Définition

class errstate(builtins.object):

help(errstate)

errstate(**kwargs)

Context manager for floating-point error handling.

Using an instance of `errstate` as a context manager allows statements in
that context to execute with a known error handling behavior. Upon entering
the context the error handling is set with `seterr` and `seterrcall`, and
upon exiting it is reset to what it was before.

..  versionchanged:: 1.17.0
    `errstate` is also usable as a function decorator, saving
    a level of indentation if an entire function is wrapped.

.. versionchanged:: 2.0
    `errstate` is now fully thread and asyncio safe, but may not be
    entered more than once.
    It is not safe to decorate async functions using ``errstate``.

Parameters
----------
kwargs : {divide, over, under, invalid}
    Keyword arguments. The valid keywords are the possible floating-point
    exceptions. Each keyword should have a string value that defines the
    treatment for the particular error. Possible values are
    {'ignore', 'warn', 'raise', 'call', 'print', 'log'}.

See Also
--------
seterr, geterr, seterrcall, geterrcall

Notes
-----
For complete documentation of the types of floating-point exceptions and
treatment options, see `seterr`.

Examples
--------
>>> import numpy as np
>>> olderr = np.seterr(all='ignore')  # Set error handling to known state.

>>> np.arange(3) / 0.
array([nan, inf, inf])
>>> with np.errstate(divide='ignore'):
...     np.arange(3) / 0.
array([nan, inf, inf])

>>> np.sqrt(-1)
np.float64(nan)
>>> with np.errstate(invalid='raise'):
...     np.sqrt(-1)
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
FloatingPointError: invalid value encountered in sqrt

Outside the context the error handling behavior has not changed:

>>> np.geterr()
{'divide': 'ignore', 'over': 'ignore', 'under': 'ignore', 'invalid': 'ignore'}
>>> olderr = np.seterr(**olderr)  # restore original state

Constructeur(s)

Signature du constructeur Description
__init__(self, *, call=<numpy._core._ufunc_config._unspecified object at 0x0000020DE89D8050>, all=None, divide=None, over=None, under=None, invalid=None)

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
__call__(self, func)
__enter__(self)
__exit__(self, *exc_info)

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __getstate__, __hash__, __init_subclass__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Vous êtes un professionnel et vous avez besoin d'une formation ? Deep Learning avec Python
et Keras et Tensorflow
Voir le programme détaillé