Author: Maciej Fijalkowski <[email protected]>
Branch:
Changeset: r51134:c14c5276c0e1
Date: 2012-01-08 15:31 +0200
http://bitbucket.org/pypy/pypy/changeset/c14c5276c0e1/
Log: minor tests and fixes
diff --git a/pypy/module/micronumpy/__init__.py
b/pypy/module/micronumpy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/micronumpy/__init__.py
@@ -48,6 +48,7 @@
'int_': 'interp_boxes.W_LongBox',
'inexact': 'interp_boxes.W_InexactBox',
'floating': 'interp_boxes.W_FloatingBox',
+ 'float_': 'interp_boxes.W_Float64Box',
'float32': 'interp_boxes.W_Float32Box',
'float64': 'interp_boxes.W_Float64Box',
}
diff --git a/pypy/module/micronumpy/interp_boxes.py
b/pypy/module/micronumpy/interp_boxes.py
--- a/pypy/module/micronumpy/interp_boxes.py
+++ b/pypy/module/micronumpy/interp_boxes.py
@@ -78,6 +78,7 @@
descr_sub = _binop_impl("subtract")
descr_mul = _binop_impl("multiply")
descr_div = _binop_impl("divide")
+ descr_pow = _binop_impl("power")
descr_eq = _binop_impl("equal")
descr_ne = _binop_impl("not_equal")
descr_lt = _binop_impl("less")
@@ -103,7 +104,7 @@
_attrs_ = ()
class W_IntegerBox(W_NumberBox):
- pass
+ descr__new__, get_dtype = new_dtype_getter("long")
class W_SignedIntegerBox(W_IntegerBox):
pass
@@ -170,6 +171,7 @@
__sub__ = interp2app(W_GenericBox.descr_sub),
__mul__ = interp2app(W_GenericBox.descr_mul),
__div__ = interp2app(W_GenericBox.descr_div),
+ __pow__ = interp2app(W_GenericBox.descr_pow),
__radd__ = interp2app(W_GenericBox.descr_radd),
__rsub__ = interp2app(W_GenericBox.descr_rsub),
@@ -198,6 +200,7 @@
)
W_IntegerBox.typedef = TypeDef("integer", W_NumberBox.typedef,
+ __new__ = interp2app(W_IntegerBox.descr__new__.im_func),
__module__ = "numpypy",
)
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
@@ -166,6 +166,15 @@
# You can't subclass dtype
raises(TypeError, type, "Foo", (dtype,), {})
+ def test_new(self):
+ import _numpypy as np
+ assert np.int_(4) == 4
+ assert np.float_(3.4) == 3.4
+
+ def test_pow(self):
+ from _numpypy import int_
+ assert int_(4) ** 2 == 16
+
class AppTestTypes(BaseNumpyAppTest):
def test_abstract_types(self):
import _numpypy as numpy
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit