提交 f1727ebe authored 作者: Arnaud Bergeron's avatar Arnaud Bergeron

Make arange always infer 64-bits for ints if the dtype is not provided.

上级 e617dc50
...@@ -4794,6 +4794,12 @@ def arange(start, stop=None, step=1, dtype=None): ...@@ -4794,6 +4794,12 @@ def arange(start, stop=None, step=1, dtype=None):
# If dtype is not provided, infer it from the other arguments # If dtype is not provided, infer it from the other arguments
if dtype is None: if dtype is None:
dtype = scal.upcast(start.type.dtype, stop.type.dtype, step.type.dtype) dtype = scal.upcast(start.type.dtype, stop.type.dtype, step.type.dtype)
# don't try to be stingy and byte-optimize, this leads to
# overflow problems.
if dtype.startswith('int'):
dtype = 'int64'
if dtype.startswith('uint'):
dtype = 'uint64'
if config.cast_policy in ('numpy', 'numpy+floatX'): if config.cast_policy in ('numpy', 'numpy+floatX'):
# We enforce numpy semantics, except in the special case where # We enforce numpy semantics, except in the special case where
# `config.cast_policy` is 'numpy+floatX' and we want to use float32 # `config.cast_policy` is 'numpy+floatX' and we want to use float32
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论