Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r58641:ee9fe199c7cb Date: 2012-10-31 15:23 +0100 http://bitbucket.org/pypy/pypy/changeset/ee9fe199c7cb/
Log: merge heads diff --git a/pypy/module/micronumpy/base.py b/pypy/module/micronumpy/base.py --- a/pypy/module/micronumpy/base.py +++ b/pypy/module/micronumpy/base.py @@ -3,6 +3,11 @@ from pypy.tool.pairtype import extendabletype from pypy.module.micronumpy.support import calc_strides +def issequence_w(space, w_obj): + return (space.isinstance_w(w_obj, space.w_tuple) or + space.isinstance_w(w_obj, space.w_list) or + isinstance(w_obj, W_NDimArray)) + class ArrayArgumentException(Exception): pass @@ -44,7 +49,7 @@ if isinstance(w_obj, W_NDimArray): return w_obj - elif space.issequence_w(w_obj): + elif issequence_w(space, w_obj): # Convert to array. return array(space, w_obj, w_order=None) else: 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 @@ -3,7 +3,7 @@ from pypy.interpreter.typedef import TypeDef, GetSetProperty from pypy.interpreter.gateway import interp2app, unwrap_spec, WrappedDefault from pypy.module.micronumpy.base import W_NDimArray, convert_to_array,\ - ArrayArgumentException + ArrayArgumentException, issequence_w from pypy.module.micronumpy import interp_dtype, interp_ufuncs, interp_boxes from pypy.module.micronumpy.strides import find_shape_and_elems,\ get_shape_from_iterable, to_coords, shape_agreement @@ -644,7 +644,7 @@ @unwrap_spec(ndmin=int, copy=bool, subok=bool) def array(space, w_object, w_dtype=None, copy=True, w_order=None, subok=False, ndmin=0): - if not space.issequence_w(w_object): + if not issequence_w(space, w_object): if space.is_none(w_dtype): w_dtype = interp_ufuncs.find_dtype_for_scalar(space, w_object) dtype = space.interp_w(interp_dtype.W_Dtype, 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 @@ -2272,6 +2272,11 @@ raises(TypeError, a, 'sum') raises(TypeError, 'a+a') + def test_string_scalar(self): + from _numpypy import array + a = array('ffff') + assert a.shape == () + def test_flexible_repr(self): # import overrides str(), repr() for array from numpypy.core import arrayprint _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit