PHP 8.0.30
Preview: test_errstate.py Size: 1.55 KB
/opt/alt/python37/lib64/python3.7/site-packages/numpy/core/tests/test_errstate.py

from __future__ import division, absolute_import, print_function

import platform

import numpy as np
from numpy.testing import TestCase, assert_, run_module_suite, dec


class TestErrstate(TestCase):
    @dec.skipif(platform.machine() == "armv5tel", "See gh-413.")
    def test_invalid(self):
        with np.errstate(all='raise', under='ignore'):
            a = -np.arange(3)
            # This should work
            with np.errstate(invalid='ignore'):
                np.sqrt(a)
            # While this should fail!
            try:
                np.sqrt(a)
            except FloatingPointError:
                pass
            else:
                self.fail("Did not raise an invalid error")

    def test_divide(self):
        with np.errstate(all='raise', under='ignore'):
            a = -np.arange(3)
            # This should work
            with np.errstate(divide='ignore'):
                a // 0
            # While this should fail!
            try:
                a // 0
            except FloatingPointError:
                pass
            else:
                self.fail("Did not raise divide by zero error")

    def test_errcall(self):
        def foo(*args):
            print(args)

        olderrcall = np.geterrcall()
        with np.errstate(call=foo):
            assert_(np.geterrcall() is foo, 'call is not foo')
            with np.errstate(call=None):
                assert_(np.geterrcall() is None, 'call is not None')
        assert_(np.geterrcall() is olderrcall, 'call is not olderrcall')


if __name__ == "__main__":
    run_module_suite()

Directory Contents

Dirs: 2 × Files: 35

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
1.97 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
18.46 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
9.98 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
90.36 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
25.16 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
18.36 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
25.59 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
38.67 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
1.55 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
5.64 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
11.16 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
4.50 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
18.21 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
4.82 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
46.84 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
3.58 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
5.83 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
1014 B lrw-r--r-- 2023-04-24 19:30:09
Edit Download
6.91 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
28.87 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
254.69 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
105.75 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
98.49 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
14.27 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
7.90 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
15.27 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
79.31 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
771 B lrw-r--r-- 2023-04-24 19:30:09
Edit Download
24.45 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
917 B lrw-r--r-- 2023-04-24 19:30:09
Edit Download
18.11 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
53.70 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
96.47 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
19.34 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download
13.90 KB lrw-r--r-- 2023-04-24 19:30:09
Edit Download

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