Author: Alex Gaynor <alex.gay...@gmail.com> Branch: Changeset: r50466:c3836e8813ff Date: 2011-12-13 13:44 -0500 http://bitbucket.org/pypy/pypy/changeset/c3836e8813ff/
Log: added __rsub__ for numpy boxes 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 @@ -86,6 +86,7 @@ descr_ge = _binop_impl("greater_equal") descr_radd = _binop_right_impl("add") + descr_rsub = _binop_right_impl("subtract") descr_rmul = _binop_right_impl("multiply") descr_neg = _unaryop_impl("negative") @@ -170,7 +171,8 @@ __mul__ = interp2app(W_GenericBox.descr_mul), __div__ = interp2app(W_GenericBox.descr_div), - __radd__ = interp2app(W_GenericBox.descr_add), + __radd__ = interp2app(W_GenericBox.descr_radd), + __rsub__ = interp2app(W_GenericBox.descr_rsub), __rmul__ = interp2app(W_GenericBox.descr_rmul), __eq__ = interp2app(W_GenericBox.descr_eq), diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py --- a/pypy/module/micronumpy/test/test_numarray.py +++ b/pypy/module/micronumpy/test/test_numarray.py @@ -491,6 +491,11 @@ for i in range(5): assert b[i] == i - 5 + def test_scalar_subtract(self): + from numpypy import int32 + assert int32(2) - 1 == 1 + assert 1 - int32(2) == -1 + def test_mul(self): import numpypy _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit