diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2020-06-01 08:47:13 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-01 08:47:13 -0500 |
commit | c25557e0a9b2d80950a8501062fc337913a3549f (patch) | |
tree | f0511de90b9c10d7756848db583c090e29e34b8e /numpy/testing/_private/utils.py | |
parent | bdd4e2e29c4b011cf455a72f85c92010656d2722 (diff) | |
parent | ff5680a0298251d8df7958f47032ac02cdea80e3 (diff) | |
download | numpy-c25557e0a9b2d80950a8501062fc337913a3549f.tar.gz |
Merge pull request #16463 from sethtroisi/tst_filter_filtered
DOC: Improve assert_warns docstring with example
Diffstat (limited to 'numpy/testing/_private/utils.py')
-rw-r--r-- | numpy/testing/_private/utils.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index f8789af90..ef623255b 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -1768,15 +1768,28 @@ def assert_warns(warning_class, *args, **kwargs): ---------- warning_class : class The class defining the warning that `func` is expected to throw. - \\*args : List of function and arguments - `func` and arguments for `func`. - \\*\\*kwargs : Kwargs + func : callable, optional + Callable to test + *args : Arguments + Arguments for `func`. + **kwargs : Kwargs Keyword arguments for `func`. Returns ------- The value returned by `func`. + Examples + -------- + >>> import warnings + >>> def deprecated_func(num): + ... warnings.warn("Please upgrade", DeprecationWarning) + ... return num*num + >>> with np.testing.assert_warns(DeprecationWarning): + ... assert deprecated_func(4) == 16 + >>> # or passing a func + >>> ret = np.testing.assert_warns(DeprecationWarning, deprecated_func, 4) + >>> assert ret == 16 """ if not args: return _assert_warns_context(warning_class) |