Author: Justin Peel <notmuchtot...@gmail.com> Branch: numpy-dtype Changeset: r46229:313d75d25bbf Date: 2011-08-03 00:06 -0600 http://bitbucket.org/pypy/pypy/changeset/313d75d25bbf/
Log: dtype can be specified as keyword to array() 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 @@ -268,7 +268,6 @@ # part of itself. can be improved. if (concrete.get_root_storage() == w_value.get_concrete().get_root_storage()): - # XXX: Need to fill in dtype w_value = new_numarray(space, w_value, self.dtype) else: w_value = convert_to_array(space, w_value) @@ -582,12 +581,16 @@ def descr_new_numarray(space, w_type, __args__): # this isn't such a great check. We should improve it including exceptions. - # Also needs to be able to handle keywords + # Also needs to be able to handle keywords better iterable = __args__.arguments_w[0] - if len(__args__.arguments_w) == 2: + if __args__.keywords: + if __args__.keywords[0] == 'dtype': + dtype = __args__.keywords_w[0] + else: + msg = "array() got unexpected keyword argument" + raise OperationError(space.w_TypeError, space.wrap(msg)) + elif len(__args__.arguments_w) == 2: dtype = __args__.arguments_w[1] - return space.wrap(new_numarray(space, __args__.arguments_w[0], - __args__.arguments_w[1])) else: # can just use the dtype for float for now. We need to actually be # able to determine the base dtype of an iterable diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py --- a/pypy/module/micronumpy/test/test_dtypes.py +++ b/pypy/module/micronumpy/test/test_dtypes.py @@ -18,10 +18,10 @@ def test_bool_array(self): from numpy import array - a = array([0, 1, 2, 2.5], '?') - assert a[0] == False + a = array([0, 1, 2, 2.5], dtype='?') + assert a[0] is False for i in xrange(1, 4): - assert a[i] == True + assert a[i] is True def test_overflow(self): from numpy import array _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit