[pypy-commit] pypy fix-result-types: Fix dtype promotion to unicode
rlamy
noreply at buildbot.pypy.org
Fri May 29 19:32:59 CEST 2015
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: fix-result-types
Changeset: r77696:e8a2003ad8ac
Date: 2015-05-29 17:17 +0100
http://bitbucket.org/pypy/pypy/changeset/e8a2003ad8ac/
Log: Fix dtype promotion to unicode
diff --git a/pypy/module/micronumpy/casting.py b/pypy/module/micronumpy/casting.py
--- a/pypy/module/micronumpy/casting.py
+++ b/pypy/module/micronumpy/casting.py
@@ -260,10 +260,10 @@
if dt2.elsize >= 4 * dt1.elsize:
return dt2
else:
- return new_unicode_dtype(space, 4 * dt1.elsize)
+ return new_unicode_dtype(space, dt1.elsize)
else: # dt1 is numeric
- dt1_size = 4 * dt1.itemtype.strlen
- if dt1_size > dt2.elsize:
+ dt1_size = dt1.itemtype.strlen
+ if 4 * dt1_size > dt2.elsize:
return new_unicode_dtype(space, dt1_size)
else:
return dt2
diff --git a/pypy/module/micronumpy/test/test_casting.py b/pypy/module/micronumpy/test/test_casting.py
--- a/pypy/module/micronumpy/test/test_casting.py
+++ b/pypy/module/micronumpy/test/test_casting.py
@@ -141,6 +141,7 @@
assert np.promote_types('>i8', '<c8') == np.dtype('complex128')
assert np.promote_types('i4', 'S8') == np.dtype('S11')
assert np.promote_types('f4', 'S8') == np.dtype('S32')
+ assert np.promote_types('f4', 'U8') == np.dtype('U32')
assert np.promote_types('?', '?') is np.dtype('?')
assert np.promote_types('?', 'float64') is np.dtype('float64')
assert np.promote_types('float64', '?') is np.dtype('float64')
More information about the pypy-commit
mailing list