[pypy-commit] pypy unsigned-dtypes: fix convert finding dtype for scalar and add a test
justinpeel
noreply at buildbot.pypy.org
Tue Sep 27 06:38:41 CEST 2011
Author: Justin Peel <notmuchtotell at gmail.com>
Branch: unsigned-dtypes
Changeset: r47618:9d20fd86887e
Date: 2011-09-26 22:38 -0600
http://bitbucket.org/pypy/pypy/changeset/9d20fd86887e/
Log: fix convert finding dtype for scalar and add a test
diff --git a/pypy/module/micronumpy/interp_ufuncs.py b/pypy/module/micronumpy/interp_ufuncs.py
--- a/pypy/module/micronumpy/interp_ufuncs.py
+++ b/pypy/module/micronumpy/interp_ufuncs.py
@@ -235,14 +235,22 @@
bool_dtype = space.fromcache(interp_dtype.W_BoolDtype)
long_dtype = space.fromcache(interp_dtype.W_LongDtype)
+ int64_dtype = space.fromcache(interp_dtype.W_Int64Dtype)
if space.is_w(w_type, space.w_bool):
- if current_guess is None:
+ if current_guess is None or current_guess is bool_dtype:
return bool_dtype
+ return current_guess
elif space.is_w(w_type, space.w_int):
if (current_guess is None or current_guess is bool_dtype or
current_guess is long_dtype):
return long_dtype
+ return current_guess
+ elif space.is_w(w_type, space.w_long):
+ if (current_guess is None or current_guess is bool_dtype or
+ current_guess is long_dtype or current_guess is int64_dtype):
+ return int64_dtype
+ return current_guess
return space.fromcache(interp_dtype.W_Float64Dtype)
diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -551,6 +551,7 @@
from numpy import array, dtype
assert array([True]).dtype is dtype(bool)
+ assert array([True, False]).dtype is dtype(bool)
assert array([True, 1]).dtype is dtype(int)
assert array([1, 2, 3]).dtype is dtype(int)
assert array([1L, 2, 3]).dtype is dtype(long)
More information about the pypy-commit
mailing list