## [PyX-checkins] pyx/test/experimental solve.py,1.7,1.8 test_solve.py,1.3,1.4

 [PyX-checkins] pyx/test/experimental solve.py,1.7,1.8 test_solve.py,1.3,1.4 From: André Wobst - 2004-08-02 08:51:58 ```Update of /cvsroot/pyx/pyx/test/experimental In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29283 Modified Files: solve.py test_solve.py Log Message: minor corrections Index: solve.py =================================================================== RCS file: /cvsroot/pyx/pyx/test/experimental/solve.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** solve.py 1 Aug 2004 20:30:34 -0000 1.7 --- solve.py 2 Aug 2004 08:51:49 -0000 1.8 *************** *** 164,168 **** return float(addend(setscalars)) else: ! return 1 def variable(self): --- 164,168 ---- return float(addend(setscalars)) else: ! return 1.0 def variable(self): *************** *** 299,308 **** def __mul__(self, other): try: other = other.vector() except (TypeError, AttributeError): try: ! polynom = other.polynom() except (TypeError, AttributeError): ! # inverse matrix multiplication return other.__rmul__(self) else: --- 299,312 ---- def __mul__(self, other): try: + other = scalar(other) + except: + pass + try: other = other.vector() except (TypeError, AttributeError): try: ! other = other.polynom() except (TypeError, AttributeError): ! # inverse matrix multiplication ? return other.__rmul__(self) else: *************** *** 486,491 **** vars.append(var) if len(vars) == l: ! a = Numeric.zeros((l, l)) ! b = Numeric.zeros((l, )) for i, eq in enumerate(eqs): for addend in eq._addends: --- 490,495 ---- vars.append(var) if len(vars) == l: ! a = Numeric.zeros((l, l), Numeric.Float) ! b = Numeric.zeros((l, ), Numeric.Float) for i, eq in enumerate(eqs): for addend in eq._addends: Index: test_solve.py =================================================================== RCS file: /cvsroot/pyx/pyx/test/experimental/test_solve.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_solve.py 1 Aug 2004 20:30:34 -0000 1.3 --- test_solve.py 2 Aug 2004 08:51:49 -0000 1.4 *************** *** 157,165 **** self.failUnlessEqual(str(2 * vector(2, "a")), "unnamed_vector{=(a[0] * unnamed_scalar{=2.0}, a[1] * unnamed_scalar{=2.0})}") self.failUnlessEqual(str(vector(2, "a") * 2), "unnamed_vector{=(a[0] * unnamed_scalar{=2.0}, a[1] * unnamed_scalar{=2.0})}") ! self.failUnlessEqual(str(scalar(name="s") * vector(2, "a")), "unnamed_vector{=(a[0] * s, a[1] * s)}") ! self.failUnlessEqual(str(scalar(name="s") * (vector(2, "a") + vector(2, "b"))), "unnamed_vector{=(a[0] * s + b[0] * s, a[1] * s + b[1] * s)}") ! self.failUnlessEqual(str((scalar(name="s") + scalar(name="t")) * vector(2, "a")), "unnamed_vector{=(a[0] * s + a[0] * t, a[1] * s + a[1] * t)}") ! self.failUnlessEqual(str((scalar(name="s") + scalar(name="t")) * (vector(2, "a") + vector(2, "b"))), "unnamed_vector{=(a[0] * s + b[0] * s + a[0] * t + b[0] * t, a[1] * s + b[1] * s + a[1] * t + b[1] * t)}") ! self.failUnlessEqual(str(vector(2, "a") * scalar(name="s")), "unnamed_vector{=(a[0] * s, a[1] * s)}") self.failUnlessEqual(str(vector(2, "a") * vector(2, "b")), "a[0] * b[0] + a[1] * b[1]") self.failUnlessRaises(RuntimeError, operator.__mul__, vector(2, "a"), vector(3)) --- 157,165 ---- self.failUnlessEqual(str(2 * vector(2, "a")), "unnamed_vector{=(a[0] * unnamed_scalar{=2.0}, a[1] * unnamed_scalar{=2.0})}") self.failUnlessEqual(str(vector(2, "a") * 2), "unnamed_vector{=(a[0] * unnamed_scalar{=2.0}, a[1] * unnamed_scalar{=2.0})}") ! self.failUnlessEqual(str(scalar(name="s") * vector(2, "a")), "unnamed_vector{=(s * a[0], s * a[1])}") ! self.failUnlessEqual(str(scalar(name="s") * (vector(2, "a") + vector(2, "b"))), "unnamed_vector{=(s * a[0] + s * b[0], s * a[1] + s * b[1])}") ! self.failUnlessEqual(str((scalar(name="s") + scalar(name="t")) * vector(2, "a")), "unnamed_vector{=(s * a[0] + t * a[0], s * a[1] + t * a[1])}") ! self.failUnlessEqual(str((scalar(name="s") + scalar(name="t")) * (vector(2, "a") + vector(2, "b"))), "unnamed_vector{=(s * a[0] + s * b[0] + t * a[0] + t * b[0], s * a[1] + s * b[1] + t * a[1] + t * b[1])}") ! self.failUnlessEqual(str(vector(2, "a") * scalar(name="s")), "unnamed_vector{=(s * a[0], s * a[1])}") self.failUnlessEqual(str(vector(2, "a") * vector(2, "b")), "a[0] * b[0] + a[1] * b[1]") self.failUnlessRaises(RuntimeError, operator.__mul__, vector(2, "a"), vector(3)) ```

 [PyX-checkins] pyx/test/experimental solve.py,1.7,1.8 test_solve.py,1.3,1.4 From: André Wobst - 2004-08-02 08:51:58 ```Update of /cvsroot/pyx/pyx/test/experimental In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29283 Modified Files: solve.py test_solve.py Log Message: minor corrections Index: solve.py =================================================================== RCS file: /cvsroot/pyx/pyx/test/experimental/solve.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** solve.py 1 Aug 2004 20:30:34 -0000 1.7 --- solve.py 2 Aug 2004 08:51:49 -0000 1.8 *************** *** 164,168 **** return float(addend(setscalars)) else: ! return 1 def variable(self): --- 164,168 ---- return float(addend(setscalars)) else: ! return 1.0 def variable(self): *************** *** 299,308 **** def __mul__(self, other): try: other = other.vector() except (TypeError, AttributeError): try: ! polynom = other.polynom() except (TypeError, AttributeError): ! # inverse matrix multiplication return other.__rmul__(self) else: --- 299,312 ---- def __mul__(self, other): try: + other = scalar(other) + except: + pass + try: other = other.vector() except (TypeError, AttributeError): try: ! other = other.polynom() except (TypeError, AttributeError): ! # inverse matrix multiplication ? return other.__rmul__(self) else: *************** *** 486,491 **** vars.append(var) if len(vars) == l: ! a = Numeric.zeros((l, l)) ! b = Numeric.zeros((l, )) for i, eq in enumerate(eqs): for addend in eq._addends: --- 490,495 ---- vars.append(var) if len(vars) == l: ! a = Numeric.zeros((l, l), Numeric.Float) ! b = Numeric.zeros((l, ), Numeric.Float) for i, eq in enumerate(eqs): for addend in eq._addends: Index: test_solve.py =================================================================== RCS file: /cvsroot/pyx/pyx/test/experimental/test_solve.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_solve.py 1 Aug 2004 20:30:34 -0000 1.3 --- test_solve.py 2 Aug 2004 08:51:49 -0000 1.4 *************** *** 157,165 **** self.failUnlessEqual(str(2 * vector(2, "a")), "unnamed_vector{=(a[0] * unnamed_scalar{=2.0}, a[1] * unnamed_scalar{=2.0})}") self.failUnlessEqual(str(vector(2, "a") * 2), "unnamed_vector{=(a[0] * unnamed_scalar{=2.0}, a[1] * unnamed_scalar{=2.0})}") ! self.failUnlessEqual(str(scalar(name="s") * vector(2, "a")), "unnamed_vector{=(a[0] * s, a[1] * s)}") ! self.failUnlessEqual(str(scalar(name="s") * (vector(2, "a") + vector(2, "b"))), "unnamed_vector{=(a[0] * s + b[0] * s, a[1] * s + b[1] * s)}") ! self.failUnlessEqual(str((scalar(name="s") + scalar(name="t")) * vector(2, "a")), "unnamed_vector{=(a[0] * s + a[0] * t, a[1] * s + a[1] * t)}") ! self.failUnlessEqual(str((scalar(name="s") + scalar(name="t")) * (vector(2, "a") + vector(2, "b"))), "unnamed_vector{=(a[0] * s + b[0] * s + a[0] * t + b[0] * t, a[1] * s + b[1] * s + a[1] * t + b[1] * t)}") ! self.failUnlessEqual(str(vector(2, "a") * scalar(name="s")), "unnamed_vector{=(a[0] * s, a[1] * s)}") self.failUnlessEqual(str(vector(2, "a") * vector(2, "b")), "a[0] * b[0] + a[1] * b[1]") self.failUnlessRaises(RuntimeError, operator.__mul__, vector(2, "a"), vector(3)) --- 157,165 ---- self.failUnlessEqual(str(2 * vector(2, "a")), "unnamed_vector{=(a[0] * unnamed_scalar{=2.0}, a[1] * unnamed_scalar{=2.0})}") self.failUnlessEqual(str(vector(2, "a") * 2), "unnamed_vector{=(a[0] * unnamed_scalar{=2.0}, a[1] * unnamed_scalar{=2.0})}") ! self.failUnlessEqual(str(scalar(name="s") * vector(2, "a")), "unnamed_vector{=(s * a[0], s * a[1])}") ! self.failUnlessEqual(str(scalar(name="s") * (vector(2, "a") + vector(2, "b"))), "unnamed_vector{=(s * a[0] + s * b[0], s * a[1] + s * b[1])}") ! self.failUnlessEqual(str((scalar(name="s") + scalar(name="t")) * vector(2, "a")), "unnamed_vector{=(s * a[0] + t * a[0], s * a[1] + t * a[1])}") ! self.failUnlessEqual(str((scalar(name="s") + scalar(name="t")) * (vector(2, "a") + vector(2, "b"))), "unnamed_vector{=(s * a[0] + s * b[0] + t * a[0] + t * b[0], s * a[1] + s * b[1] + t * a[1] + t * b[1])}") ! self.failUnlessEqual(str(vector(2, "a") * scalar(name="s")), "unnamed_vector{=(s * a[0], s * a[1])}") self.failUnlessEqual(str(vector(2, "a") * vector(2, "b")), "a[0] * b[0] + a[1] * b[1]") self.failUnlessRaises(RuntimeError, operator.__mul__, vector(2, "a"), vector(3)) ```