Skip to content

Commit

Permalink
FIX: doc example
Browse files Browse the repository at this point in the history
  • Loading branch information
dengemann committed Nov 29, 2013
1 parent 9fd2be4 commit a4e67d6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions sklearn/utils/testing.py
Expand Up @@ -152,15 +152,14 @@ def ignore_warnings(obj=None):
--------
>>> with ignore_warnings():
... warnings.warn('buhuhuhu')
>>>
>>>def nasty_warn():
>>> def nasty_warn():
... warnings.warn('buhuhuhu')
... print 42
>>>
>>> ignore_warnings(nasty_warn)()
42
"""
if callable(obj):
return _ignore_warnings(obj)
Expand All @@ -173,9 +172,9 @@ def _ignore_warnings(fn):
@wraps(fn)
def wrapper(*args, **kwargs):
# very important to avoid uncontrolled state propagation
clean_warning_registry()
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
clean_warning_registry()
return fn(*args, **kwargs)
w[:] = []

Expand Down

0 comments on commit a4e67d6

Please sign in to comment.