Fail if the given callable produces any warnings. If called with all arguments omitted, may be used as a context manager: with assert_no_warnings(): do_something() The ability to be used as a context manager is new in NumPy v1.11.0. .. versionadded:: 1.7.0
(*args, **kwargs)
| 1789 | |
| 1790 | |
| 1791 | def assert_no_warnings(*args, **kwargs): |
| 1792 | """ |
| 1793 | Fail if the given callable produces any warnings. |
| 1794 | |
| 1795 | If called with all arguments omitted, may be used as a context manager: |
| 1796 | |
| 1797 | with assert_no_warnings(): |
| 1798 | do_something() |
| 1799 | |
| 1800 | The ability to be used as a context manager is new in NumPy v1.11.0. |
| 1801 | |
| 1802 | .. versionadded:: 1.7.0 |
| 1803 | |
| 1804 | Parameters |
| 1805 | ---------- |
| 1806 | func : callable |
| 1807 | The callable to test. |
| 1808 | \\*args : Arguments |
| 1809 | Arguments passed to `func`. |
| 1810 | \\*\\*kwargs : Kwargs |
| 1811 | Keyword arguments passed to `func`. |
| 1812 | |
| 1813 | Returns |
| 1814 | ------- |
| 1815 | The value returned by `func`. |
| 1816 | |
| 1817 | """ |
| 1818 | if not args: |
| 1819 | return _assert_no_warnings_context() |
| 1820 | |
| 1821 | func = args[0] |
| 1822 | args = args[1:] |
| 1823 | with _assert_no_warnings_context(name=func.__name__): |
| 1824 | return func(*args, **kwargs) |
| 1825 | |
| 1826 | |
| 1827 | def _gen_alignment_data(dtype=float32, type='binary', max_size=24): |