class_docstr: 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
  --------
  >>> 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
class_docstr_tok: ["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","--","--","--","--",">",">",">","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"]
code: def __call__(self, func):
      # We need to customize `__call__` compared to `ContextDecorator`
      # because we must store the token per-thread so cannot store it on
      # the instance (we could create a new instance for this).
      # This duplicates the code from `__enter__`.
      @functools.wraps(func)
      def inner(*args, **kwargs):
          if self._call is _Unspecified:
              extobj = _make_extobj(
                  all=self._all,
                  divide=self._divide,
                  over=self._over,
                  under=self._under,
                  invalid=self._invalid,
              )
          else:
              extobj = _make_extobj(
                  call=self._call,
                  all=self._all,
                  divide=self._divide,
                  over=self._over,
                  under=self._under,
                  invalid=self._invalid,
              )
  
          _token = _extobj_contextvar.set(extobj)
          try:
              # Call the original, decorated, function:
              return func(*args, **kwargs)
          finally:
              _extobj_contextvar.reset(_token)
  
      return inner
  
file_path: numpy/numpy/_core/_ufunc_config.py
imports: import collections.abc
  import contextlib
  import contextvars
  import functools
  from .._utils import set_module
  from .umath import _make_extobj, _get_extobj_dict, _extobj_contextvar
label_desc: Use image node_id 4 for calling the errstate obj's underlying member method code with example usage: obj.__call__(func) and returns: inner, func