[pypy-commit] pypy default: fix Issue1389 and Issue1281: we need to interpret the dtype before doing the comparison with the existing one
antocuni
noreply at buildbot.pypy.org
Mon Feb 11 17:34:11 CET 2013
Author: Antonio Cuni <anto.cuni at gmail.com>
Branch:
Changeset: r61096:2d3671965584
Date: 2013-02-11 17:32 +0100
http://bitbucket.org/pypy/pypy/changeset/2d3671965584/
Log: fix Issue1389 and Issue1281: we need to interpret the dtype before
doing the comparison with the existing one
diff --git a/pypy/module/micronumpy/interp_numarray.py b/pypy/module/micronumpy/interp_numarray.py
--- a/pypy/module/micronumpy/interp_numarray.py
+++ b/pypy/module/micronumpy/interp_numarray.py
@@ -904,15 +904,17 @@
if order != 'C': # or order != 'F':
raise operationerrfmt(space.w_ValueError, "Unknown order: %s",
order)
+
+ dtype = interp_dtype.decode_w_dtype(space, w_dtype)
if isinstance(w_object, W_NDimArray):
if (not space.is_none(w_dtype) and
- w_object.get_dtype() is not w_dtype):
+ w_object.get_dtype() is not dtype):
raise OperationError(space.w_NotImplementedError, space.wrap(
"copying over different dtypes unsupported"))
if copy:
return w_object.descr_copy(space)
return w_object
- dtype = interp_dtype.decode_w_dtype(space, w_dtype)
+
shape, elems_w = find_shape_and_elems(space, w_object, dtype)
if dtype is None:
for w_elem in elems_w:
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
@@ -1733,6 +1733,13 @@
assert a[1] == 0xff
assert len(a.data) == 16
+
+ def test_explicit_dtype_conversion(self):
+ from _numpypy import array
+ a = array([1.0, 2.0])
+ b = array(a, dtype='d')
+ assert a.dtype is b.dtype
+
class AppTestMultiDim(BaseNumpyAppTest):
def test_init(self):
import _numpypy
More information about the pypy-commit
mailing list