class_docstr: Context manager that resets warning registry for catching warnings.
  
  Warnings can be slippery, because, whenever a warning is triggered, Python
  adds a ``__warningregistry__`` member to the *calling* module.  This makes
  it impossible to retrigger the warning in this module, whatever you put in
  the warnings filters.  This context manager accepts a sequence of `modules`
  as a keyword argument to its constructor and:
  * stores and removes any ``__warningregistry__`` entries in given `modules`
    on entry;
  * resets ``__warningregistry__`` to its previous state on exit.
  This makes it possible to trigger any warning afresh inside the context
  manager without disturbing the state of warnings outside.
  For compatibility with Python 3.0, please consider all arguments to be
  keyword-only.
  
  Parameters
  ----------
  record : bool, optional
      Specifies whether warnings should be captured by a custom
      implementation of ``warnings.showwarning()`` and be appended to a list
      returned by the context manager. Otherwise None is returned by the
      context manager. The objects appended to the list are arguments whose
      attributes mirror the arguments to ``showwarning()``.
      NOTE: nibabel difference from numpy: default is True
  modules : sequence, optional
      Sequence of modules for which to reset warnings registry on entry and
      restore on exit
  
  Examples
  --------
  >>> import warnings
  >>> with clear_and_catch_warnings(modules=[np.core.fromnumeric]):
  ...     warnings.simplefilter('always')
  ...     # do something that raises a warning in np.core.fromnumeric
  
  Notes
  -----
  this class is copied (with minor modifications) from Nibabel.
  https://github.com/nipy/nibabel. See COPYING file distributed along with
  the Nibabel package for the copyright and license terms.
class_docstr_tok: ["Context","manager","that","resets","warning","registry","for","catching","warnings",".","Warnings","can","be","slippery",",","because",",","whenever","a","warning","is","triggered",",","Python","adds","a","``","__warningregistry__","``","member","to","the","*","calling","*","module",".","This","makes","it","impossible","to","retrigger","the","warning","in","this","module",",","whatever","you","put","in","the","warnings","filters",".","This","context","manager","accepts","a","sequence","of","`","modules","`","as","a","keyword","argument","to","its","constructor","and",":","*","stores","and","removes","any","``","__warningregistry__","``","entries","in","given","`","modules","`","on","entry",";","*","resets","``","__warningregistry__","``","to","its","previous","state","on","exit",".","This","makes","it","possible","to","trigger","any","warning","afresh","inside","the","context","manager","without","disturbing","the","state","of","warnings","outside",".","For","compatibility","with","Python","3.0",",","please","consider","all","arguments","to","be","keyword-only",".","Parameters","--","--","--","--","--","record",":","bool",",","optional","Specifies","whether","warnings","should","be","captured","by","a","custom","implementation","of","``","warnings.showwarning","(",")","``","and","be","appended","to","a","list","returned","by","the","context","manager",".","Otherwise","None","is","returned","by","the","context","manager",".","The","objects","appended","to","the","list","are","arguments","whose","attributes","mirror","the","arguments","to","``","showwarning","(",")","``",".","NOTE",":","nibabel","difference","from","numpy",":","default","is","True","modules",":","sequence",",","optional","Sequence","of","modules","for","which","to","reset","warnings","registry","on","entry","and","restore","on","exit","Examples","--","--","--","--",">",">",">","import","warnings",">",">",">","with","clear_and_catch_warnings","(","modules=","[","np.core.fromnumeric","]",")",":","...","warnings.simplefilter","(","'always","'",")","...","#","do","something","that","raises","a","warning","in","np.core.fromnumeric","Notes","--","--","-","this","class","is","copied","(","with","minor","modifications",")","from","Nibabel",".","https",":","\/\/github.com\/nipy\/nibabel",".","See","COPYING","file","distributed","along","with","the","Nibabel","package","for","the","copyright","and","license","terms","."]
code: def __exit__(self, *exc_info):
      super(clear_and_catch_warnings, self).__exit__(*exc_info)
      for mod in self.modules:
          if hasattr(mod, "__warningregistry__"):
              mod.__warningregistry__.clear()
          if mod in self._warnreg_copies:
              mod.__warningregistry__.update(self._warnreg_copies[mod])
  
file_path: dipy/dipy/testing/__init__.py
imports: import operator
  from functools import partial
  from os.path import dirname, abspath, join
  from numpy.testing import assert_array_equal
  import numpy
  import numpy.testing
  import scipy
  from packaging.version import Version
  import warnings
label_desc: Use image node_id 3 for calling the clear_and_catch_warnings obj's underlying member method code with example usage: obj.__exit__() without return types