File: test_machar.py

package info (click to toggle)
python-numpy 1%3A1.4.1-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 12,736 kB
  • ctags: 14,035
  • sloc: ansic: 80,776; python: 62,482; makefile: 183; fortran: 121; f90: 42; cpp: 28; perl: 19; sh: 15
file content (31 lines) | stat: -rw-r--r-- 1,000 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from numpy.testing import *

from numpy.core.machar import MachAr
import numpy.core.numerictypes as ntypes
from numpy import seterr, array

class TestMachAr(TestCase):
    def _run_machar_highprec(self):
        # Instanciate MachAr instance with high enough precision to cause
        # underflow
        try:
            hiprec = ntypes.float96
            machar = MachAr(lambda v:array([v], hiprec))
        except AttributeError:
            "Skipping test: no nyptes.float96 available on this platform."

    def test_underlow(self):
        """Regression testing for #759: instanciating MachAr for dtype =
        np.float96 raises spurious warning."""
        serrstate = seterr(all='raise')
        try:
            try:
                self._run_machar_highprec()
            except FloatingPointError, e:
                self.fail("Caught %s exception, should not have been raised." % e)
        finally:
            seterr(**serrstate)


if __name__ == "__main__":
    run_module_suite()