OXIESEC PANEL
- Current Dir:
/
/
usr
/
lib
/
python3
/
dist-packages
/
numpy
/
core
/
tests
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
10/28/2024 08:45:52 AM
rwxr-xr-x
📁
__pycache__
-
10/28/2024 08:45:52 AM
rwxr-xr-x
📁
data
-
10/28/2024 08:45:52 AM
rwxr-xr-x
📄
test_abc.py
1.97 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_api.py
18.46 KB
09/17/2017 01:29:38 PM
rw-r--r--
📄
test_arrayprint.py
9.98 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_datetime.py
90.36 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_defchararray.py
25.16 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_deprecations.py
18.36 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_dtype.py
25.59 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_einsum.py
38.67 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_errstate.py
1.55 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_extint128.py
5.64 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_function_base.py
11.16 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_getlimits.py
4.5 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_half.py
18.21 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_indexerrors.py
4.82 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_indexing.py
46.84 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_item_selection.py
3.58 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_longdouble.py
5.83 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_machar.py
1014 bytes
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_mem_overlap.py
28.87 KB
09/17/2017 01:29:38 PM
rw-r--r--
📄
test_memmap.py
6.91 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_multiarray.py
254.69 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_nditer.py
105.75 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_numeric.py
98.49 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_numerictypes.py
14.27 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_print.py
7.9 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_records.py
15.27 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_regression.py
79.31 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_scalarinherit.py
771 bytes
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_scalarmath.py
24.45 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_scalarprint.py
917 bytes
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_shape_base.py
18.11 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_ufunc.py
53.7 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_umath.py
96.47 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_umath_complex.py
19.34 KB
09/29/2017 05:31:46 PM
rw-r--r--
📄
test_unicode.py
13.9 KB
09/29/2017 05:31:46 PM
rw-r--r--
Editing: test_getlimits.py
Close
""" Test functions for limits module. """ from __future__ import division, absolute_import, print_function import numpy as np from numpy.core import finfo, iinfo from numpy import half, single, double, longdouble from numpy.testing import ( TestCase, run_module_suite, assert_equal, assert_ ) from numpy.core.getlimits import (_discovered_machar, _float16_ma, _float32_ma, _float64_ma, _float128_ma, _float80_ma) ################################################## class TestPythonFloat(TestCase): def test_singleton(self): ftype = finfo(float) ftype2 = finfo(float) assert_equal(id(ftype), id(ftype2)) class TestHalf(TestCase): def test_singleton(self): ftype = finfo(half) ftype2 = finfo(half) assert_equal(id(ftype), id(ftype2)) class TestSingle(TestCase): def test_singleton(self): ftype = finfo(single) ftype2 = finfo(single) assert_equal(id(ftype), id(ftype2)) class TestDouble(TestCase): def test_singleton(self): ftype = finfo(double) ftype2 = finfo(double) assert_equal(id(ftype), id(ftype2)) class TestLongdouble(TestCase): def test_singleton(self,level=2): ftype = finfo(longdouble) ftype2 = finfo(longdouble) assert_equal(id(ftype), id(ftype2)) class TestFinfo(TestCase): def test_basic(self): dts = list(zip(['f2', 'f4', 'f8', 'c8', 'c16'], [np.float16, np.float32, np.float64, np.complex64, np.complex128])) for dt1, dt2 in dts: for attr in ('bits', 'eps', 'epsneg', 'iexp', 'machar', 'machep', 'max', 'maxexp', 'min', 'minexp', 'negep', 'nexp', 'nmant', 'precision', 'resolution', 'tiny'): assert_equal(getattr(finfo(dt1), attr), getattr(finfo(dt2), attr), attr) self.assertRaises(ValueError, finfo, 'i4') class TestIinfo(TestCase): def test_basic(self): dts = list(zip(['i1', 'i2', 'i4', 'i8', 'u1', 'u2', 'u4', 'u8'], [np.int8, np.int16, np.int32, np.int64, np.uint8, np.uint16, np.uint32, np.uint64])) for dt1, dt2 in dts: for attr in ('bits', 'min', 'max'): assert_equal(getattr(iinfo(dt1), attr), getattr(iinfo(dt2), attr), attr) self.assertRaises(ValueError, iinfo, 'f4') def test_unsigned_max(self): types = np.sctypes['uint'] for T in types: assert_equal(iinfo(T).max, T(-1)) class TestRepr(TestCase): def test_iinfo_repr(self): expected = "iinfo(min=-32768, max=32767, dtype=int16)" assert_equal(repr(np.iinfo(np.int16)), expected) def test_finfo_repr(self): expected = "finfo(resolution=1e-06, min=-3.4028235e+38," + \ " max=3.4028235e+38, dtype=float32)" assert_equal(repr(np.finfo(np.float32)), expected) def test_instances(): iinfo(10) finfo(3.0) def assert_ma_equal(discovered, ma_like): # Check MachAr-like objects same as calculated MachAr instances for key, value in discovered.__dict__.items(): assert_equal(value, getattr(ma_like, key)) if hasattr(value, 'shape'): assert_equal(value.shape, getattr(ma_like, key).shape) assert_equal(value.dtype, getattr(ma_like, key).dtype) def test_known_types(): # Test we are correctly compiling parameters for known types for ftype, ma_like in ((np.float16, _float16_ma), (np.float32, _float32_ma), (np.float64, _float64_ma)): assert_ma_equal(_discovered_machar(ftype), ma_like) # Suppress warning for broken discovery of double double on PPC with np.errstate(all='ignore'): ld_ma = _discovered_machar(np.longdouble) bytes = np.dtype(np.longdouble).itemsize if (ld_ma.it, ld_ma.maxexp) == (63, 16384) and bytes in (12, 16): # 80-bit extended precision assert_ma_equal(ld_ma, _float80_ma) elif (ld_ma.it, ld_ma.maxexp) == (112, 16384) and bytes == 16: # IEE 754 128-bit assert_ma_equal(ld_ma, _float128_ma) def test_plausible_finfo(): # Assert that finfo returns reasonable results for all types for ftype in np.sctypes['float'] + np.sctypes['complex']: info = np.finfo(ftype) assert_(info.nmant > 1) assert_(info.minexp < -1) assert_(info.maxexp > 1) if __name__ == "__main__": run_module_suite()