Author: Justin Peel <notmuchtot...@gmail.com> Branch: unsigned-dtypes Changeset: r46969:779c6bc0669f Date: 2011-08-31 22:15 -0600 http://bitbucket.org/pypy/pypy/changeset/779c6bc0669f/
Log: Add UInt32 dtype diff --git a/pypy/module/micronumpy/interp_dtype.py b/pypy/module/micronumpy/interp_dtype.py --- a/pypy/module/micronumpy/interp_dtype.py +++ b/pypy/module/micronumpy/interp_dtype.py @@ -14,6 +14,7 @@ from pypy.rpython.lltypesystem import lltype, rffi +UNSIGNEDLTR = "u" SIGNEDLTR = "i" BOOLLTR = "b" FLOATINGLTR = "f" @@ -313,6 +314,17 @@ class W_Int32Dtype(IntegerArithmeticDtype, W_Int32Dtype): pass +W_UInt32Dtype = create_low_level_dtype( + num = 6, kind = UNSIGNEDLTR, name = "uint32", + aliases = ["I"], + applevel_types = [], + T = rffi.UINT, + valtype = rffi.UINT._type, + expected_size = 4, +) +class W_UInt32Dtype(IntegerArithmeticDtype, W_UInt32Dtype): + pass + W_Int64Dtype = create_low_level_dtype( num = 9, kind = SIGNEDLTR, name = "int64", aliases = [], @@ -341,7 +353,8 @@ ALL_DTYPES = [ W_BoolDtype, - W_Int8Dtype, W_Int16Dtype, W_Int32Dtype, W_Int64Dtype, + W_Int8Dtype, W_Int16Dtype, W_Int32Dtype, W_UInt32Dtype, + W_Int64Dtype, W_Float64Dtype ] 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 @@ -99,6 +99,15 @@ for i in range(5): assert b[i] == i * 2 + def test_add_uint32(self): + from numpy import array, dtype + + a = array(range(5), dtype="I") + b = a + a + assert b.dtype is dtype("I") + for i in range(5): + assert b[i] == i * 2 + def test_shape(self): from numpy import dtype _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit