diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2021-02-11 09:53:57 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-11 09:53:57 -0600 |
commit | 01c9bfe4f48d23ec2d2db50ffc58d6e5e42cbe93 (patch) | |
tree | 29c70d2fd3bf73e9d86b1a88d75c1342384511b3 | |
parent | 871009f6415a2f588230e2e36bc9dbe751698ee1 (diff) | |
parent | 703b55f6f171811a39cce6581df50d4532fbcf74 (diff) | |
download | numpy-01c9bfe4f48d23ec2d2db50ffc58d6e5e42cbe93.tar.gz |
Merge pull request #18396 from bashtage/clean-random
MAINT: Threading and Unicode strings
-rw-r--r-- | numpy/distutils/ccompiler.py | 6 | ||||
-rw-r--r-- | numpy/distutils/misc_util.py | 5 | ||||
-rw-r--r-- | numpy/random/_common.pyx | 4 | ||||
-rw-r--r-- | numpy/random/_generator.pyx | 6 | ||||
-rw-r--r-- | numpy/random/_philox.pyx | 5 | ||||
-rw-r--r-- | numpy/random/bit_generator.pyx | 9 |
6 files changed, 11 insertions, 24 deletions
diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py index 106436e64..f025c8904 100644 --- a/numpy/distutils/ccompiler.py +++ b/numpy/distutils/ccompiler.py @@ -26,10 +26,8 @@ from numpy.distutils.misc_util import cyg2win32, is_sequence, mingw32, \ _commandline_dep_string # globals for parallel build management -try: - import threading -except ImportError: - import dummy_threading as threading +import threading + _job_semaphore = None _global_lock = threading.Lock() _processing_files = set() diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index 5392663d6..37e120072 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -10,13 +10,10 @@ import shutil import multiprocessing import textwrap import importlib.util +from threading import local as tlocal import distutils from distutils.errors import DistutilsError -try: - from threading import local as tlocal -except ImportError: - from dummy_threading import local as tlocal # stores temporary directory of each thread to only create one per thread _tdata = tlocal() diff --git a/numpy/random/_common.pyx b/numpy/random/_common.pyx index 6d77aed03..19fb34d4d 100644 --- a/numpy/random/_common.pyx +++ b/numpy/random/_common.pyx @@ -25,11 +25,11 @@ cdef uint64_t MAXSIZE = <uint64_t>sys.maxsize cdef object benchmark(bitgen_t *bitgen, object lock, Py_ssize_t cnt, object method): """Benchmark command used by BitGenerator""" cdef Py_ssize_t i - if method==u'uint64': + if method=='uint64': with lock, nogil: for i in range(cnt): bitgen.next_uint64(bitgen.state) - elif method==u'double': + elif method=='double': with lock, nogil: for i in range(cnt): bitgen.next_double(bitgen.state) diff --git a/numpy/random/_generator.pyx b/numpy/random/_generator.pyx index 9673bc6f4..cc7991eb1 100644 --- a/numpy/random/_generator.pyx +++ b/numpy/random/_generator.pyx @@ -386,7 +386,7 @@ cdef class Generator: 0.0, '', CONS_NONE, None) - def standard_exponential(self, size=None, dtype=np.float64, method=u'zig', out=None): + def standard_exponential(self, size=None, dtype=np.float64, method='zig', out=None): """ standard_exponential(size=None, dtype=np.float64, method='zig', out=None) @@ -426,12 +426,12 @@ cdef class Generator: """ _dtype = np.dtype(dtype) if _dtype == np.float64: - if method == u'zig': + if method == 'zig': return double_fill(&random_standard_exponential_fill, &self._bitgen, size, self.lock, out) else: return double_fill(&random_standard_exponential_inv_fill, &self._bitgen, size, self.lock, out) elif _dtype == np.float32: - if method == u'zig': + if method == 'zig': return float_fill(&random_standard_exponential_fill_f, &self._bitgen, size, self.lock, out) else: return float_fill(&random_standard_exponential_inv_fill_f, &self._bitgen, size, self.lock, out) diff --git a/numpy/random/_philox.pyx b/numpy/random/_philox.pyx index 7e8880490..0fe8ebd7c 100644 --- a/numpy/random/_philox.pyx +++ b/numpy/random/_philox.pyx @@ -1,10 +1,5 @@ from cpython.pycapsule cimport PyCapsule_New -try: - from threading import Lock -except ImportError: - from dummy_threading import Lock - import numpy as np cimport numpy as np diff --git a/numpy/random/bit_generator.pyx b/numpy/random/bit_generator.pyx index 9b0c363ef..123d77b40 100644 --- a/numpy/random/bit_generator.pyx +++ b/numpy/random/bit_generator.pyx @@ -43,10 +43,7 @@ except ImportError: from random import SystemRandom randbits = SystemRandom().getrandbits -try: - from threading import Lock -except ImportError: - from dummy_threading import Lock +from threading import Lock from cpython.pycapsule cimport PyCapsule_New @@ -587,8 +584,8 @@ cdef class BitGenerator(): """ return random_raw(&self._bitgen, self.lock, size, output) - def _benchmark(self, Py_ssize_t cnt, method=u'uint64'): - '''Used in tests''' + def _benchmark(self, Py_ssize_t cnt, method='uint64'): + """Used in tests""" return benchmark(&self._bitgen, self.lock, cnt, method) @property |