Author: Brian Kearns <[email protected]>
Branch:
Changeset: r67719:9a9e3d3b03cc
Date: 2013-10-29 20:58 -0400
http://bitbucket.org/pypy/pypy/changeset/9a9e3d3b03cc/
Log: fix some missing dtype aliases
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
@@ -491,6 +491,7 @@
char=NPY_BOOLLTR,
w_box_type=space.gettypefor(interp_boxes.W_BoolBox),
alternate_constructors=[space.w_bool],
+ aliases=['bool8'],
)
self.w_int8dtype = W_Dtype(
types.Int8(),
@@ -498,7 +499,8 @@
kind=NPY_SIGNEDLTR,
name="int8",
char=NPY_BYTELTR,
- w_box_type=space.gettypefor(interp_boxes.W_Int8Box)
+ w_box_type=space.gettypefor(interp_boxes.W_Int8Box),
+ aliases=['byte'],
)
self.w_uint8dtype = W_Dtype(
types.UInt8(),
@@ -507,6 +509,7 @@
name="uint8",
char=NPY_UBYTELTR,
w_box_type=space.gettypefor(interp_boxes.W_UInt8Box),
+ aliases=['ubyte'],
)
self.w_int16dtype = W_Dtype(
types.Int16(),
@@ -515,6 +518,7 @@
name="int16",
char=NPY_SHORTLTR,
w_box_type=space.gettypefor(interp_boxes.W_Int16Box),
+ aliases=['short'],
)
self.w_uint16dtype = W_Dtype(
types.UInt16(),
@@ -523,6 +527,7 @@
name="uint16",
char=NPY_USHORTLTR,
w_box_type=space.gettypefor(interp_boxes.W_UInt16Box),
+ aliases=['ushort'],
)
self.w_int32dtype = W_Dtype(
types.Int32(),
@@ -572,6 +577,7 @@
char=NPY_LONGLONGLTR,
w_box_type=space.gettypefor(interp_boxes.W_Int64Box),
alternate_constructors=[space.w_long],
+ aliases=['longlong'],
)
self.w_uint64dtype = W_Dtype(
types.UInt64(),
@@ -580,6 +586,7 @@
name="uint64",
char=NPY_ULONGLONGLTR,
w_box_type=space.gettypefor(interp_boxes.W_UInt64Box),
+ aliases=['ulonglong'],
)
self.w_float32dtype = W_Dtype(
types.Float32(),
@@ -588,6 +595,7 @@
name="float32",
char=NPY_FLOATLTR,
w_box_type=space.gettypefor(interp_boxes.W_Float32Box),
+ aliases=['single']
)
self.w_float64dtype = W_Dtype(
types.Float64(),
@@ -617,6 +625,7 @@
name="complex64",
char=NPY_CFLOATLTR,
w_box_type = space.gettypefor(interp_boxes.W_Complex64Box),
+ aliases=['csingle'],
float_type = self.w_float32dtype,
)
self.w_complex128dtype = W_Dtype(
@@ -627,7 +636,7 @@
char=NPY_CDOUBLELTR,
w_box_type = space.gettypefor(interp_boxes.W_Complex128Box),
alternate_constructors=[space.w_complex],
- aliases=["complex"],
+ aliases=["complex", 'cfloat', 'cdouble'],
float_type = self.w_float64dtype,
)
self.w_complexlongdtype = W_Dtype(
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
@@ -56,8 +56,21 @@
def test_dtype_aliases(self):
from numpypy import dtype
+ assert dtype('bool8') is dtype('bool')
+ assert dtype('byte') is dtype('int8')
+ assert dtype('ubyte') is dtype('uint8')
+ assert dtype('short') is dtype('int16')
+ assert dtype('ushort') is dtype('uint16')
+ assert dtype('longlong') is dtype('q')
+ assert dtype('ulonglong') is dtype('Q')
+ assert dtype("float") is dtype(float)
+ assert dtype('single') is dtype('float32')
+ assert dtype('double') is dtype('float64')
assert dtype('longfloat').num in (12, 13)
assert dtype('longdouble').num in (12, 13)
+ assert dtype('csingle') is dtype('complex64')
+ assert dtype('cfloat') is dtype('complex128')
+ assert dtype('cdouble') is dtype('complex128')
assert dtype('clongfloat').num in (15, 16)
assert dtype('clongdouble').num in (15, 16)
@@ -223,10 +236,6 @@
pass
assert True
- def test_aliases(self):
- from numpypy import dtype
- assert dtype("float") is dtype(float)
-
def test_index(self):
import numpypy as np
for dtype in [np.int8, np.int16, np.int32, np.int64]:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit