summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorSeth Troisi <sethtroisi@google.com>2020-01-28 11:39:46 -0800
committerSebastian Berg <sebastian@sipsolutions.net>2020-01-28 11:39:46 -0800
commit96727cf007217256700a1d805569a73d2171f1d5 (patch)
treeb31b6381b620029b1f3fc702243b0816380ee299 /numpy
parentd67de1bfaaa8b9e01c367c34bf76ff86124bf8dc (diff)
downloadnumpy-96727cf007217256700a1d805569a73d2171f1d5.tar.gz
MAINT: Remove sys.version checks (gh-#15373)
More sys.version cleanup.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/_dtype.py16
-rw-r--r--numpy/core/_type_aliases.py19
-rw-r--r--numpy/distutils/fcompiler/pg.py108
-rw-r--r--numpy/f2py/capi_maps.py6
-rw-r--r--numpy/lib/utils.py35
-rwxr-xr-xnumpy/linalg/lapack_lite/make_lite.py7
-rw-r--r--numpy/ma/core.py5
7 files changed, 58 insertions, 138 deletions
diff --git a/numpy/core/_dtype.py b/numpy/core/_dtype.py
index fa39dfcd4..6b0ec5903 100644
--- a/numpy/core/_dtype.py
+++ b/numpy/core/_dtype.py
@@ -3,8 +3,6 @@ A place for code to be called from the implementation of np.dtype
String handling is much easier to do correctly in python.
"""
-import sys
-
import numpy as np
@@ -17,18 +15,10 @@ _kind_to_stem = {
'V': 'void',
'O': 'object',
'M': 'datetime',
- 'm': 'timedelta'
+ 'm': 'timedelta',
+ 'S': 'bytes',
+ 'U': 'str',
}
-if sys.version_info[0] >= 3:
- _kind_to_stem.update({
- 'S': 'bytes',
- 'U': 'str'
- })
-else:
- _kind_to_stem.update({
- 'S': 'string',
- 'U': 'unicode'
- })
def _kind_name(dtype):
diff --git a/numpy/core/_type_aliases.py b/numpy/core/_type_aliases.py
index d6e1a1fb7..dfb70430f 100644
--- a/numpy/core/_type_aliases.py
+++ b/numpy/core/_type_aliases.py
@@ -203,22 +203,16 @@ def _set_up_aliases():
('bool_', 'bool'),
('bytes_', 'string'),
('string_', 'string'),
+ ('str_', 'unicode'),
('unicode_', 'unicode'),
('object_', 'object')]
- if sys.version_info[0] >= 3:
- type_pairs.extend([('str_', 'unicode')])
- else:
- type_pairs.extend([('str_', 'string')])
for alias, t in type_pairs:
allTypes[alias] = allTypes[t]
sctypeDict[alias] = sctypeDict[t]
# Remove aliases overriding python types and modules
to_remove = ['ulong', 'object', 'int', 'float',
- 'complex', 'bool', 'string', 'datetime', 'timedelta']
- if sys.version_info[0] >= 3:
- to_remove.extend(['bytes', 'str'])
- else:
- to_remove.extend(['unicode', 'long'])
+ 'complex', 'bool', 'string', 'datetime', 'timedelta',
+ 'bytes', 'str']
for t in to_remove:
try:
@@ -267,11 +261,8 @@ _set_array_types()
# Add additional strings to the sctypeDict
-_toadd = ['int', 'float', 'complex', 'bool', 'object']
-if sys.version_info[0] >= 3:
- _toadd.extend(['str', 'bytes', ('a', 'bytes_')])
-else:
- _toadd.extend(['string', ('str', 'string_'), 'unicode', ('a', 'string_')])
+_toadd = ['int', 'float', 'complex', 'bool', 'object',
+ 'str', 'bytes', ('a', 'bytes_')]
for name in _toadd:
if isinstance(name, tuple):
diff --git a/numpy/distutils/fcompiler/pg.py b/numpy/distutils/fcompiler/pg.py
index 77bc4f08e..f3f96bbf2 100644
--- a/numpy/distutils/fcompiler/pg.py
+++ b/numpy/distutils/fcompiler/pg.py
@@ -62,72 +62,60 @@ class PGroupFCompiler(FCompiler):
return '-R%s' % dir
-if sys.version_info >= (3, 5):
- import functools
+import functools
+
+class PGroupFlangCompiler(FCompiler):
+ compiler_type = 'flang'
+ description = 'Portland Group Fortran LLVM Compiler'
+ version_pattern = r'\s*(flang|clang) version (?P<version>[\d.-]+).*'
+
+ ar_exe = 'lib.exe'
+ possible_executables = ['flang']
+
+ executables = {
+ 'version_cmd': ["<F77>", "--version"],
+ 'compiler_f77': ["flang"],
+ 'compiler_fix': ["flang"],
+ 'compiler_f90': ["flang"],
+ 'linker_so': [None],
+ 'archiver': [ar_exe, "/verbose", "/OUT:"],
+ 'ranlib': None
+ }
+
+ library_switch = '/OUT:' # No space after /OUT:!
+ module_dir_switch = '-module ' # Don't remove ending space!
+
+ def get_libraries(self):
+ opt = FCompiler.get_libraries(self)
+ opt.extend(['flang', 'flangrti', 'ompstub'])
+ return opt
+
+ @functools.lru_cache(maxsize=128)
+ def get_library_dirs(self):
+ """List of compiler library directories."""
+ opt = FCompiler.get_library_dirs(self)
+ flang_dir = dirname(self.executables['compiler_f77'][0])
+ opt.append(normpath(join(flang_dir, '..', 'lib')))
+
+ return opt
- class PGroupFlangCompiler(FCompiler):
- compiler_type = 'flang'
- description = 'Portland Group Fortran LLVM Compiler'
- version_pattern = r'\s*(flang|clang) version (?P<version>[\d.-]+).*'
-
- ar_exe = 'lib.exe'
- possible_executables = ['flang']
-
- executables = {
- 'version_cmd': ["<F77>", "--version"],
- 'compiler_f77': ["flang"],
- 'compiler_fix': ["flang"],
- 'compiler_f90': ["flang"],
- 'linker_so': [None],
- 'archiver': [ar_exe, "/verbose", "/OUT:"],
- 'ranlib': None
- }
-
- library_switch = '/OUT:' # No space after /OUT:!
- module_dir_switch = '-module ' # Don't remove ending space!
-
- def get_libraries(self):
- opt = FCompiler.get_libraries(self)
- opt.extend(['flang', 'flangrti', 'ompstub'])
- return opt
-
- @functools.lru_cache(maxsize=128)
- def get_library_dirs(self):
- """List of compiler library directories."""
- opt = FCompiler.get_library_dirs(self)
- flang_dir = dirname(self.executables['compiler_f77'][0])
- opt.append(normpath(join(flang_dir, '..', 'lib')))
-
- return opt
-
- def get_flags(self):
- return []
-
- def get_flags_free(self):
- return []
-
- def get_flags_debug(self):
- return ['-g']
-
- def get_flags_opt(self):
- return ['-O3']
+ def get_flags(self):
+ return []
- def get_flags_arch(self):
- return []
+ def get_flags_free(self):
+ return []
- def runtime_library_dir_option(self, dir):
- raise NotImplementedError
+ def get_flags_debug(self):
+ return ['-g']
-else:
- from numpy.distutils.fcompiler import CompilerNotFound
+ def get_flags_opt(self):
+ return ['-O3']
- # No point in supporting on older Pythons because not ABI compatible
- class PGroupFlangCompiler(FCompiler):
- compiler_type = 'flang'
- description = 'Portland Group Fortran LLVM Compiler'
+ def get_flags_arch(self):
+ return []
- def get_version(self):
- raise CompilerNotFound('Flang unsupported on Python < 3.5')
+ def runtime_library_dir_option(self, dir):
+ raise NotImplementedError
if __name__ == '__main__':
diff --git a/numpy/f2py/capi_maps.py b/numpy/f2py/capi_maps.py
index 6f9ff7bc6..bbfcf1a24 100644
--- a/numpy/f2py/capi_maps.py
+++ b/numpy/f2py/capi_maps.py
@@ -147,11 +147,7 @@ c2buildvalue_map = {'double': 'd',
'complex_float': 'N',
'complex_double': 'N',
'complex_long_double': 'N',
- 'string': 'z'}
-
-if sys.version_info[0] >= 3:
- # Bytes, not Unicode strings
- c2buildvalue_map['string'] = 'y'
+ 'string': 'y'}
if using_newcore:
# c2buildvalue_map=???
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py
index 152322115..f81b4e6e4 100644
--- a/numpy/lib/utils.py
+++ b/numpy/lib/utils.py
@@ -605,41 +605,6 @@ def info(object=None, maxwidth=76, output=sys.stdout, toplevel='numpy'):
)
print(" %s -- %s" % (meth, methstr), file=output)
- elif (sys.version_info[0] < 3
- and isinstance(object, types.InstanceType)):
- # check for __call__ method
- # types.InstanceType is the type of the instances of oldstyle classes
- print("Instance of class: ", object.__class__.__name__, file=output)
- print(file=output)
- if hasattr(object, '__call__'):
- arguments = formatargspec(
- *getargspec(object.__call__.__func__)
- )
- arglist = arguments.split(', ')
- if len(arglist) > 1:
- arglist[1] = "("+arglist[1]
- arguments = ", ".join(arglist[1:])
- else:
- arguments = "()"
-
- if hasattr(object, 'name'):
- name = "%s" % object.name
- else:
- name = "<name>"
- if len(name+arguments) > maxwidth:
- argstr = _split_line(name, arguments, maxwidth)
- else:
- argstr = name + arguments
-
- print(" " + argstr + "\n", file=output)
- doc = inspect.getdoc(object.__call__)
- if doc is not None:
- print(inspect.getdoc(object.__call__), file=output)
- print(inspect.getdoc(object), file=output)
-
- else:
- print(inspect.getdoc(object), file=output)
-
elif inspect.ismethod(object):
name = object.__name__
arguments = formatargspec(
diff --git a/numpy/linalg/lapack_lite/make_lite.py b/numpy/linalg/lapack_lite/make_lite.py
index 960f5e2d8..7c2d110fa 100755
--- a/numpy/linalg/lapack_lite/make_lite.py
+++ b/numpy/linalg/lapack_lite/make_lite.py
@@ -20,12 +20,7 @@ import shutil
import fortran
import clapack_scrub
-PY2 = sys.version_info < (3, 0)
-
-if PY2:
- from distutils.spawn import find_executable as which
-else:
- from shutil import which
+from shutil import which
# Arguments to pass to f2c. You'll always want -A for ANSI C prototypes
# Others of interest: -a to not make variables static by default
diff --git a/numpy/ma/core.py b/numpy/ma/core.py
index 4f9f453fd..e24cb956c 100644
--- a/numpy/ma/core.py
+++ b/numpy/ma/core.py
@@ -21,7 +21,6 @@ Released for unlimited redistribution.
"""
# pylint: disable-msg=E1002
import builtins
-import sys
import operator
import warnings
import textwrap
@@ -3885,10 +3884,6 @@ class MaskedArray(ndarray):
def __str__(self):
return str(self._insert_masked_print())
- if sys.version_info.major < 3:
- def __unicode__(self):
- return unicode(self._insert_masked_print())
-
def __repr__(self):
"""
Literal string representation.