Author: Brian Kearns <[email protected]>
Branch:
Changeset: r68506:7126a9a7a21e
Date: 2013-12-19 23:41 -0500
http://bitbucket.org/pypy/pypy/changeset/7126a9a7a21e/
Log: fix dtype creation from some abstract numpy types
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
@@ -662,6 +662,7 @@
w_box_type = space.gettypefor(interp_boxes.W_Float64Box),
alternate_constructors=[space.w_float,
space.gettypefor(interp_boxes.W_NumberBox),
+
space.gettypefor(interp_boxes.W_FloatingBox),
],
aliases=["float", "double"],
)
@@ -691,7 +692,8 @@
name="complex128",
char=NPY_CDOUBLELTR,
w_box_type = space.gettypefor(interp_boxes.W_Complex128Box),
- alternate_constructors=[space.w_complex],
+ alternate_constructors=[space.w_complex,
+
space.gettypefor(interp_boxes.W_ComplexFloatingBox)],
aliases=["complex", 'cfloat', 'cdouble'],
float_type = self.w_float64dtype,
)
@@ -713,7 +715,8 @@
name='string',
char=NPY_STRINGLTR,
w_box_type = space.gettypefor(interp_boxes.W_StringBox),
- alternate_constructors=[space.w_str,
space.gettypefor(interp_boxes.W_CharacterBox)],
+ alternate_constructors=[space.w_str,
+
space.gettypefor(interp_boxes.W_CharacterBox)],
aliases=["str"],
)
self.w_unicodedtype = 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
@@ -369,16 +369,22 @@
# numpy allows abstract types in array creation
a_n = numpy.array([4,4], numpy.number)
+ a_f = numpy.array([4,4], numpy.floating)
+ a_c = numpy.array([4,4], numpy.complexfloating)
a_i = numpy.array([4,4], numpy.integer)
a_s = numpy.array([4,4], numpy.signedinteger)
a_u = numpy.array([4,4], numpy.unsignedinteger)
assert a_n.dtype.num == 12
+ assert a_f.dtype.num == 12
+ assert a_c.dtype.num == 15
assert a_i.dtype.num == 7
assert a_s.dtype.num == 7
assert a_u.dtype.num == 8
assert a_n.dtype is numpy.dtype('float64')
+ assert a_f.dtype is numpy.dtype('float64')
+ assert a_c.dtype is numpy.dtype('complex128')
if self.ptr_size == 4:
assert a_i.dtype is numpy.dtype('int32')
assert a_s.dtype is numpy.dtype('int32')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit