diff options
| author | Pauli Virtanen <pav@iki.fi> | 2019-12-04 20:49:56 +0200 |
|---|---|---|
| committer | Pauli Virtanen <pav@iki.fi> | 2019-12-04 20:55:07 +0200 |
| commit | d3f6a7eddc68c9160db695106d196cebbc8d9fd4 (patch) | |
| tree | 5753414a695100400478db78be609b3993a11ab4 /numpy | |
| parent | 8f6bdf83f40c22a76f75c42b7dacf34f0229082f (diff) | |
| download | numpy-d3f6a7eddc68c9160db695106d196cebbc8d9fd4.tar.gz | |
TST: fix up issues in requires_memory decorator
Fix wrong multiplier for /proc/meminfo, and do style cleanups.
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/lib/tests/test_io.py | 2 | ||||
| -rw-r--r-- | numpy/linalg/tests/test_linalg.py | 2 | ||||
| -rw-r--r-- | numpy/testing/_private/decorators.py | 4 | ||||
| -rw-r--r-- | numpy/testing/_private/utils.py | 11 |
4 files changed, 8 insertions, 11 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index 4188265e8..39fe40685 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -576,7 +576,7 @@ class TestSaveTxt(object): @pytest.mark.skipif(sys.platform=='win32', reason="large files cause problems") @pytest.mark.slow - @requires_memory(7e9) + @requires_memory(free_bytes=7e9) def test_large_zip(self): # The test takes at least 6GB of memory, writes a file larger than 4GB test_data = np.asarray([np.random.rand(np.random.randint(50,100),4) diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py index e1590f1e7..bd3df1ca4 100644 --- a/numpy/linalg/tests/test_linalg.py +++ b/numpy/linalg/tests/test_linalg.py @@ -2008,7 +2008,7 @@ def test_unsupported_commontype(): @pytest.mark.slow @pytest.mark.xfail(not HAS_LAPACK64, run=False, reason="Numpy not compiled with 64-bit BLAS/LAPACK") -@requires_memory(16e9) +@requires_memory(free_bytes=16e9) def test_blas64_dot(): n = 2**32 a = np.zeros([1, n], dtype=np.float32) diff --git a/numpy/testing/_private/decorators.py b/numpy/testing/_private/decorators.py index eab40e7c9..24c4e385d 100644 --- a/numpy/testing/_private/decorators.py +++ b/numpy/testing/_private/decorators.py @@ -15,10 +15,6 @@ function name, setup and teardown functions and so on - see """ from __future__ import division, absolute_import, print_function -import sys -import os -import re - try: # Accessing collections abstract classes from collections # has been deprecated since Python 3.3 diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index 4642cc0f8..32bd738bc 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -2417,9 +2417,10 @@ def requires_memory(free_bytes): def _parse_size(size_str): """Convert memory size strings ('12 GB' etc.) to float""" - suffixes = {'': 1.0, 'b': 1.0, - 'k': 1e3, 'm': 1e6, 'g': 1e9, 't': 1e12, - 'kb': 1e3, 'mb': 1e6, 'gb': 1e9, 'tb': 1e12} + suffixes = {'': 1, 'b': 1, + 'k': 1000, 'm': 1000**2, 'g': 1000**3, 't': 1000**4, + 'kb': 1000, 'mb': 1000**2, 'gb': 1000**3, 'tb': 1000**4, + 'kib': 1024, 'mib': 1024**2, 'gib': 1024**3, 'tib': 1024**4} size_re = re.compile(r'^\s*(\d+|\d+\.\d+)\s*({0})\s*$'.format( '|'.join(suffixes.keys())), re.I) @@ -2427,7 +2428,7 @@ def _parse_size(size_str): m = size_re.match(size_str.lower()) if not m or m.group(2) not in suffixes: raise ValueError("value {!r} not a valid size".format(size_str)) - return float(m.group(1)) * suffixes[m.group(2)] + return int(float(m.group(1)) * suffixes[m.group(2)]) def _get_mem_available(): @@ -2443,7 +2444,7 @@ def _get_mem_available(): with open('/proc/meminfo', 'r') as f: for line in f: p = line.split() - info[p[0].strip(':').lower()] = float(p[1]) * 1e3 + info[p[0].strip(':').lower()] = int(p[1]) * 1024 if 'memavailable' in info: # Linux >= 3.14 |
