summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2018-09-20 23:28:33 -0700
committerEric Wieser <wieser.eric@gmail.com>2018-09-20 23:32:25 -0700
commit1e4695914143a0e1544387c97cd970cfeafd404d (patch)
treeaacab28f7580206dc20bf9f13d145c14c5c7a02c
parent7248c1d8ccfa3643a9286c46bd134b2e113ba85f (diff)
downloadnumpy-1e4695914143a0e1544387c97cd970cfeafd404d.tar.gz
MAINT: Reassociate `np.cast` with the comment describing it
-rw-r--r--numpy/core/numerictypes.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py
index 1cb32a0ec..8100a764f 100644
--- a/numpy/core/numerictypes.py
+++ b/numpy/core/numerictypes.py
@@ -746,9 +746,10 @@ def sctype2char(sctype):
# Create dictionary of casting functions that wrap sequences
# indexed by type or type character
-
-
cast = _typedict()
+for key in _sctype2char_dict.keys():
+ cast[key] = lambda x, k=key: array(x, copy=False).astype(k)
+
try:
ScalarType = [_types.IntType, _types.FloatType, _types.ComplexType,
_types.LongType, _types.BooleanType,
@@ -759,8 +760,6 @@ except AttributeError:
ScalarType.extend(_sctype2char_dict.keys())
ScalarType = tuple(ScalarType)
-for key in _sctype2char_dict.keys():
- cast[key] = lambda x, k=key: array(x, copy=False).astype(k)
# Create the typestring lookup dictionary
_typestr = _typedict()
@@ -776,7 +775,6 @@ for key, val in _typestr.items():
sctypeDict[val] = key
# Add additional strings to the sctypeDict
-
if sys.version_info[0] >= 3:
_toadd = ['int', 'float', 'complex', 'bool', 'object',
'str', 'bytes', 'object', ('a', allTypes['bytes_'])]