summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2018-09-21 12:41:11 +0300
committerGitHub <noreply@github.com>2018-09-21 12:41:11 +0300
commit6f0a0fafdd0b315cb46fca553beaff769af6e0da (patch)
tree8d0e00f9b4bd196e22f3d45de4b764ce613877bb
parent14db73763d913072475d6968a0a7c78fc1a42edf (diff)
parent1e4695914143a0e1544387c97cd970cfeafd404d (diff)
downloadnumpy-6f0a0fafdd0b315cb46fca553beaff769af6e0da.tar.gz
Merge pull request #12008 from eric-wieser/cast-comments
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 bdaa88cb8..f0cd8ec74 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,11 +760,8 @@ 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)
# Add additional strings to the sctypeDict
-
if sys.version_info[0] >= 3:
_toadd = ['int', 'float', 'complex', 'bool', 'object',
'str', 'bytes', 'object', ('a', allTypes['bytes_'])]