Author: Brian Kearns <[email protected]>
Branch:
Changeset: r68494:5076b09e7c83
Date: 2013-12-19 17:15 -0500
http://bitbucket.org/pypy/pypy/changeset/5076b09e7c83/
Log: simplify/fix some intp attributes
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
@@ -735,38 +735,21 @@
char=NPY_HALFLTR,
w_box_type=space.gettypefor(interp_boxes.W_Float16Box),
)
- ptr_size = rffi.sizeof(rffi.CCHARP)
- if ptr_size == 4:
- intp_box = interp_boxes.W_Int32Box
- intp_type = types.Int32()
- intp_num = NPY_INT
- uintp_box = interp_boxes.W_UInt32Box
- uintp_type = types.UInt32()
- uintp_num = NPY_UINT
- elif ptr_size == 8:
- intp_box = interp_boxes.W_Int64Box
- intp_type = types.Int64()
- intp_num = NPY_LONG
- uintp_box = interp_boxes.W_UInt64Box
- uintp_type = types.UInt64()
- uintp_num = NPY_ULONG
- else:
- raise ValueError('unknown point size %d' % ptr_size)
self.w_intpdtype = W_Dtype(
- intp_type,
- num=intp_num,
- kind=NPY_INTPLTR,
+ types.Long(),
+ num=NPY_LONG,
+ kind=NPY_SIGNEDLTR,
name='intp',
char=NPY_INTPLTR,
- w_box_type = space.gettypefor(intp_box),
+ w_box_type = space.gettypefor(interp_boxes.W_LongBox),
)
self.w_uintpdtype = W_Dtype(
- uintp_type,
- num=uintp_num,
- kind=NPY_UINTPLTR,
+ types.ULong(),
+ num=NPY_ULONG,
+ kind=NPY_UNSIGNEDLTR,
name='uintp',
char=NPY_UINTPLTR,
- w_box_type = space.gettypefor(uintp_box),
+ w_box_type = space.gettypefor(interp_boxes.W_ULongBox),
)
float_dtypes = [self.w_float16dtype, self.w_float32dtype,
self.w_float64dtype, self.w_floatlongdtype]
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
@@ -715,10 +715,14 @@
assert numpy.int16 is numpy.short
assert numpy.int8 is numpy.byte
assert numpy.bool_ is numpy.bool8
+ assert numpy.intp().dtype.num == 7
+ assert numpy.intp().dtype.char == 'l'
if self.ptr_size == 4:
+ assert numpy.intp().dtype.name == 'int32'
assert numpy.intp is numpy.int32
assert numpy.uintp is numpy.uint32
elif self.ptr_size == 8:
+ assert numpy.intp().dtype.name == 'int64'
assert numpy.intp is numpy.int64
assert numpy.uintp is numpy.uint64
@@ -787,8 +791,22 @@
def test_intp(self):
from numpypy import dtype
- assert dtype('p') == dtype('intp')
- assert dtype('P') == dtype('uintp')
+ assert dtype('p') is dtype('intp')
+ assert dtype('P') is dtype('uintp')
+ #assert dtype('p') is dtype('int')
+ #assert dtype('P') is dtype('uint')
+ assert dtype('p').num == 7
+ assert dtype('P').num == 8
+ #assert dtype('p').char == 'l'
+ #assert dtype('P').char == 'L'
+ assert dtype('p').kind == 'i'
+ assert dtype('P').kind == 'u'
+ #if self.ptr_size == 4:
+ # assert dtype('p').name == 'int32'
+ # assert dtype('P').name == 'uint32'
+ #else:
+ # assert dtype('p').name == 'int64'
+ # assert dtype('P').name == 'uint64'
def test_alignment(self):
from numpypy import dtype
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit