diff options
author | Brigitta Sipocz <bsipocz@gmail.com> | 2020-07-12 13:50:02 -0700 |
---|---|---|
committer | Brigitta Sipőcz <bsipocz@gmail.com> | 2022-05-17 20:11:34 -0700 |
commit | 497dc9402d04754b512e344c8039caafd55351da (patch) | |
tree | 67d6b59afac53f31dda3f7dfe937a197a220ed00 /numpy | |
parent | 59aad3cf436691d447e43038e3402500f13cd817 (diff) | |
download | numpy-497dc9402d04754b512e344c8039caafd55351da.tar.gz |
Remove python <3.6 related things
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/_add_newdocs.py | 3 | ||||
-rw-r--r-- | numpy/core/include/numpy/npy_3kcompat.h | 2 | ||||
-rw-r--r-- | numpy/distutils/misc_util.py | 5 | ||||
-rw-r--r-- | numpy/lib/format.py | 2 | ||||
-rw-r--r-- | numpy/random/bit_generator.pyx | 8 | ||||
-rw-r--r-- | numpy/testing/_private/utils.py | 3 | ||||
-rw-r--r-- | numpy/testing/tests/test_utils.py | 16 |
7 files changed, 10 insertions, 29 deletions
diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py index 304c3a61b..2706093d2 100644 --- a/numpy/core/_add_newdocs.py +++ b/numpy/core/_add_newdocs.py @@ -1316,8 +1316,7 @@ add_newdoc('numpy.core.multiarray', 'fromstring', decimal numbers, an operation which is better spelt ``frombuffer(string, dtype, count)``. If `string` contains unicode text, the binary mode of `fromstring` will first encode it into - bytes using either utf-8 (python 3) or the default encoding - (python 2), neither of which produce sane results. + bytes using utf-8 (python 3) which does not produce sane results. ${ARRAY_FUNCTION_LIKE} .. versionadded:: 1.20.0 diff --git a/numpy/core/include/numpy/npy_3kcompat.h b/numpy/core/include/numpy/npy_3kcompat.h index 22c103e93..1ea897f55 100644 --- a/numpy/core/include/numpy/npy_3kcompat.h +++ b/numpy/core/include/numpy/npy_3kcompat.h @@ -1,6 +1,6 @@ /* * This is a convenience header file providing compatibility utilities - * for supporting Python 2 and Python 3 in the same code base. + * for supporting different minor versions of Python 3. * * If you want to use this for your own projects, it's recommended to make a * copy of it. Although the stuff below is unlikely to change, we don't provide diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index 513be75db..0bee5a8ec 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -699,10 +699,7 @@ def get_shared_lib_extension(is_python_ext=False): """ confvars = distutils.sysconfig.get_config_vars() - # SO is deprecated in 3.3.1, use EXT_SUFFIX instead - so_ext = confvars.get('EXT_SUFFIX', None) - if so_ext is None: - so_ext = confvars.get('SO', '') + so_ext = confvars.get('EXT_SUFFIX', '') if not is_python_ext: # hardcode known values, config vars (including SHLIB_SUFFIX) are diff --git a/numpy/lib/format.py b/numpy/lib/format.py index 264fff8d6..dfd50b393 100644 --- a/numpy/lib/format.py +++ b/numpy/lib/format.py @@ -370,7 +370,7 @@ def _wrap_header(header, version): import struct assert version is not None fmt, encoding = _header_size_info[version] - if not isinstance(header, bytes): # always true on python 3 + if not isinstance(header, bytes): header = header.encode(encoding) hlen = len(header) + 1 padlen = ARRAY_ALIGN - ((MAGIC_LEN + struct.calcsize(fmt) + hlen) % ARRAY_ALIGN) diff --git a/numpy/random/bit_generator.pyx b/numpy/random/bit_generator.pyx index fe45f85b0..2c50dbf70 100644 --- a/numpy/random/bit_generator.pyx +++ b/numpy/random/bit_generator.pyx @@ -35,13 +35,7 @@ import abc import sys from itertools import cycle import re - -try: - from secrets import randbits -except ImportError: - # secrets unavailable on python 3.5 and before - from random import SystemRandom - randbits = SystemRandom().getrandbits +from secrets import randbits from threading import Lock diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index 80a6fdd10..4a8f42e06 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -1342,9 +1342,6 @@ def assert_raises_regex(exception_class, expected_regexp, *args, **kwargs): Alternatively, can be used as a context manager like `assert_raises`. - Name of this function adheres to Python 3.2+ reference, but should work in - all versions down to 2.6. - Notes ----- .. versionadded:: 1.9.0 diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py index 919ca751f..1aaa8f559 100644 --- a/numpy/testing/tests/test_utils.py +++ b/numpy/testing/tests/test_utils.py @@ -212,7 +212,7 @@ class TestArrayEqual(_GenericTest): with pytest.raises(AssertionError): with np.errstate(all="raise"): np.testing.assert_array_equal( - np.array([1, 2, 3], np.float32), + np.array([1, 2, 3], np.float32), np.array([1, 1e-40, 3], np.float32)) @@ -1224,7 +1224,7 @@ class TestStringEqual: lambda: assert_string_equal("aaa", "a+b")) -def assert_warn_len_equal(mod, n_in_context, py34=None, py37=None): +def assert_warn_len_equal(mod, n_in_context, py37=None): try: mod_warns = mod.__warningregistry__ except AttributeError: @@ -1238,10 +1238,7 @@ def assert_warn_len_equal(mod, n_in_context, py34=None, py37=None): mod_warns = {} num_warns = len(mod_warns) - # Python 3.4 appears to clear any pre-existing warnings of the same type, - # when raising warnings inside a catch_warnings block. So, there is a - # warning generated by the tests within the context manager, but no - # previous warnings. + if 'version' in mod_warns: # Python 3 adds a 'version' entry to the registry, # do not count it. @@ -1253,9 +1250,7 @@ def assert_warn_len_equal(mod, n_in_context, py34=None, py37=None): if sys.version_info[:2] >= (3, 7): if py37 is not None: n_in_context = py37 - else: - if py34 is not None: - n_in_context = py34 + assert_equal(num_warns, n_in_context) def test_warn_len_equal_call_scenarios(): @@ -1318,12 +1313,11 @@ def test_clear_and_catch_warnings(): warnings.warn('Another warning') assert_warn_len_equal(my_mod, 1, py37=0) # Another warning, no module spec does add to warnings dict, except on - # Python 3.4 (see comments in `assert_warn_len_equal`) # Python 3.7 catch_warnings doesn't make an entry for 'ignore'. with clear_and_catch_warnings(): warnings.simplefilter('ignore') warnings.warn('Another warning') - assert_warn_len_equal(my_mod, 2, py34=1, py37=0) + assert_warn_len_equal(my_mod, 2, py37=0) def test_suppress_warnings_module(): |