Author: Brian Kearns <bdkea...@gmail.com> Branch: Changeset: r69319:f2ff6d660efd Date: 2014-02-23 19:17 -0500 http://bitbucket.org/pypy/pypy/changeset/f2ff6d660efd/
Log: fix ndarray.astype(S0) 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 @@ -572,6 +572,10 @@ if new_dtype.num == NPY.VOID: raise oefmt(space.w_NotImplementedError, "%s.astype(%s) not implemented yet", cur_dtype.name, new_dtype.name) + if new_dtype.num == NPY.STRING and new_dtype.size == 0: + if cur_dtype.num == NPY.STRING: + new_dtype = interp_dtype.variable_dtype(space, + 'S' + str(cur_dtype.size)) impl = self.implementation if isinstance(impl, scalar.Scalar): return W_NDimArray.new_scalar(space, new_dtype, impl.value) 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 @@ -2102,6 +2102,7 @@ assert a[2] == 3.0 a = array('123') + assert a.astype('S0').dtype == 'S3' assert a.astype('i8') == 123 a = array('abcdefgh') exc = raises(ValueError, a.astype, 'i8') _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit