Author: mattip <[email protected]>
Branch: str-dtype-improvement
Changeset: r62346:351a29aeb5e8
Date: 2013-03-14 12:10 -0700
http://bitbucket.org/pypy/pypy/changeset/351a29aeb5e8/
Log: cannot implement astype('S3') without StringType.box, but box would
require an unavailable space instance to convert values to strings
diff --git a/pypy/module/micronumpy/arrayimpl/concrete.py
b/pypy/module/micronumpy/arrayimpl/concrete.py
--- a/pypy/module/micronumpy/arrayimpl/concrete.py
+++ b/pypy/module/micronumpy/arrayimpl/concrete.py
@@ -276,6 +276,9 @@
return ArrayBuffer(self)
def astype(self, space, dtype):
+ if dtype.is_flexible_type():
+ raise OperationError(space.w_NotImplementedError, space.wrap(
+ "astype(%s) not implemented yet" % dtype))
new_arr = W_NDimArray.from_shape(self.get_shape(), dtype)
loop.copy_from_to(self, new_arr.implementation, dtype)
return new_arr
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
@@ -1646,8 +1646,11 @@
a = array('x').astype('S3').dtype
assert a.itemsize == 3
- a = array([1, 2, 3.14156]).astype('S3').dtype
- assert a.itemsize == 3
+ try:
+ a = array([1, 2, 3.14156]).astype('S3').dtype
+ assert a.itemsize == 3
+ except NotImplementedError:
+ skip('astype("S3") not implemented for numeric arrays')
def test_base(self):
from numpypy import array
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit