diff -r 0202bb3a6d74 pypy/module/micronumpy/numarray.py--- a/pypy/module/micronumpy/numarray.py Wed May 04 23:20:11 2011 +0200+++ b/pypy/module/micronumpy/numarray.py Wed May 04 15:31:01 2011 -0600@@ -125,6 +125,11 @@ b = frame.popvalue() a = frame.popvalue() frame.pushvalue(a * b)+ elif opcode == 's':+ # Subtract.+ a = frame.popvalue()+ b = frame.popvalue()+ frame.pushvalue(a - b) else: raise NotImplementedError( "Can't handle bytecode instruction %s" % opcode)@@ -145,6 +150,13 @@ # (we still have to compile new bytecode, but too bad) return compute(code)+ def descr_sub(self, space, w_other):+ if isinstance(w_other, BaseArray):+ return space.wrap(BinOp('s', self, w_other))+ else:+ return space.wrap(BinOp('s', self,+ FloatWrapper(space.float_w(w_other))))+ def descr_add(self, space, w_other): if isinstance(w_other, BaseArray): return space.wrap(BinOp('a', self, w_other))@@ -192,6 +204,7 @@ 'Operation', force = interp2app(BaseArray.force), __add__ = interp2app(BaseArray.descr_add),+ __sub__ = interp2app(BaseArray.descr_sub), __mul__ = interp2app(BaseArray.descr_mul), )@@ -251,6 +264,7 @@ __getitem__ = interp2app(SingleDimArray.descr_getitem), __setitem__ = interp2app(SingleDimArray.descr_setitem), __add__ = interp2app(BaseArray.descr_add),+ __sub__ = interp2app(BaseArray.descr_sub), __mul__ = interp2app(BaseArray.descr_mul), force = interp2app(SingleDimArray.force), )diff -r 0202bb3a6d74 pypy/module/micronumpy/test/test_numpy.py--- a/pypy/module/micronumpy/test/test_numpy.py Wed May 04 23:20:11 2011 +0200+++ b/pypy/module/micronumpy/test/test_numpy.py Wed May 04 15:31:01 2011 -0600@@ -6,6 +6,8 @@ cls.space = gettestobjspace(usemodules=('micronumpy',)) def test_init(self):+ import numpy, sys+ print >>sys.stderr, numpy from numpy import zeros a = zeros(15) # Check that storage was actually zero'd.@@ -27,6 +29,14 @@ for i in range(5): assert b[i] == i + i+ def test_subtract(self):+ from numpy import array+ a = array(range(5))+ b = (a - a).force()+ b = b.force()+ for i in range(5):+ assert b[i] == 0+ def test_add_other(self): from numpy import array a = array(range(5))@@ -36,6 +46,18 @@ for i in range(5): assert c[i] == 4+ def test_subtract_other(self):+ from numpy import array+ a = array(range(5))+ b = array([1, 1, 1, 1, 1])+ c = (a - b).force()+ for i in range(5):+ assert c[i] == (i - 1), (i, c[i])++ d = (b - a).force()+ for i in range(5):+ assert d[i] == (1 - i), (i, c[i])+ def test_add_constant(self): from numpy import array a = array(range(5))@@ -44,6 +66,14 @@ for i in range(5): assert b[i] == i + 5+ def test_add_constant(self):+ from numpy import array+ a = array(range(5))+ b = a - 5+ b = b.force()+ for i in range(5):+ assert b[i] == i - 5+ def test_mul(self): from numpy import array a = array(range(5))