PHP 8.0.30
Preview: test_utils.py Size: 1.62 KB
/opt/alt/python37/lib64/python3.7/site-packages/numpy/lib/tests/test_utils.py

from __future__ import division, absolute_import, print_function

import sys
from numpy.core import arange
from numpy.testing import (
    run_module_suite, assert_, assert_equal, assert_raises_regex, dec
    )
from numpy.lib import deprecate
import numpy.lib.utils as utils

if sys.version_info[0] >= 3:
    from io import StringIO
else:
    from StringIO import StringIO


@dec.skipif(sys.flags.optimize == 2)
def test_lookfor():
    out = StringIO()
    utils.lookfor('eigenvalue', module='numpy', output=out,
                  import_modules=False)
    out = out.getvalue()
    assert_('numpy.linalg.eig' in out)


@deprecate
def old_func(self, x):
    return x


@deprecate(message="Rather use new_func2")
def old_func2(self, x):
    return x


def old_func3(self, x):
    return x
new_func3 = deprecate(old_func3, old_name="old_func3", new_name="new_func3")


def test_deprecate_decorator():
    assert_('deprecated' in old_func.__doc__)


def test_deprecate_decorator_message():
    assert_('Rather use new_func2' in old_func2.__doc__)


def test_deprecate_fn():
    assert_('old_func3' in new_func3.__doc__)
    assert_('new_func3' in new_func3.__doc__)


def test_safe_eval_nameconstant():
    # Test if safe_eval supports Python 3.4 _ast.NameConstant
    utils.safe_eval('None')


def test_byte_bounds():
    a = arange(12).reshape(3, 4)
    low, high = utils.byte_bounds(a)
    assert_equal(high - low, a.size * a.itemsize)


def test_assert_raises_regex_context_manager():
    with assert_raises_regex(ValueError, 'no deprecation warning'):
        raise ValueError('no deprecation warning')


if __name__ == "__main__":
    run_module_suite()

Directory Contents

Dirs: 2 × Files: 23

Name Size Perms Modified Actions
data DIR
- drwxr-xr-x 2023-05-13 02:18:14
Edit Download
- drwxr-xr-x 2023-05-13 02:18:14
Edit Download
42.68 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
15.49 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
1.42 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
6.62 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
33.49 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
126.81 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
13.10 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
75.59 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
6.70 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
34.07 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
12.63 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
7.03 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
30.54 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
8.62 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
19.02 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
14.69 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
16.72 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
12.62 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
2.96 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
1.62 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
10.16 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
13.15 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download
2.08 KB lrw-r--r-- 2023-04-24 19:30:08
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).