Author: Lukas Diekmann <lukas.diekm...@uni-duesseldorf.de> Branch: Changeset: r47162:e6ecaadbcaf8 Date: 2011-09-08 14:51 +0200 http://bitbucket.org/pypy/pypy/changeset/e6ecaadbcaf8/
Log: merge 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 @@ -317,6 +317,17 @@ class W_Int8Dtype(IntegerArithmeticDtype, W_Int8Dtype): pass +W_UInt8Dtype = create_low_level_dtype( + num = 1, kind = SIGNEDLTR, name = "uint8", + aliases = ["uint8"], + applevel_types = [], + T = rffi.UCHAR, + valtype = rffi.UCHAR._type, + expected_size = 1, +) +class W_UInt8Dtype(IntegerArithmeticDtype, W_UInt8Dtype): + pass + W_Int16Dtype = create_low_level_dtype( num = 3, kind = SIGNEDLTR, name = "int16", aliases = ["int16"], @@ -368,6 +379,7 @@ ALL_DTYPES = [ W_BoolDtype, W_Int8Dtype, W_Int16Dtype, W_Int32Dtype, W_Int64Dtype, + W_UInt8Dtype, 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 @@ -12,6 +12,7 @@ assert dtype(d) is d assert dtype(None) is dtype(float) raises(TypeError, dtype, 1042) + assert dtype('uint8').num == 1 def test_dtype_with_types(self): from numpy import dtype @@ -90,6 +91,15 @@ for i in range(5): assert b[i] == i * 2 + def test_add_uint8(self): + from numpy import array, dtype + + a = array(range(5), dtype="uint8") + b = a + a + assert b.dtype is dtype("uint8") + for i in range(5): + assert b[i] == i * 2 + def test_add_int16(self): from numpy import array, dtype @@ -109,3 +119,15 @@ # You can't subclass dtype raises(TypeError, type, "Foo", (dtype,), {}) + + def test_int_ranges(self): + from numpy import array + for dtype, minval, maxval in [("int8", -128, 127), + ("uint8", 0, 255), + ("int16", -32768, 32767)]: + a = array([minval, maxval, minval-1, maxval+1], dtype) + assert a[0] == minval + assert a[1] == maxval + assert a[2] == maxval + assert a[3] == minval + _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit