Permalink
Browse files

rewrote the known_bugs

  • Loading branch information...
1 parent 2e2479e commit cbd38f873584c9a96210fbaa236afe851c209d68 b45ch1 committed Dec 25, 2009
Showing with 40 additions and 34 deletions.
  1. +40 −34 tests/known_bugs.py
View
74 tests/known_bugs.py
@@ -1,49 +1,55 @@
import numpy
-import adolc
-import os
-
-class oofun:
- __array_priority__ = 1000
- def __init__(self,x):
+class adouble:
+ def __init__(self,x):
self.x = x
-
- def __mul__(self, rhs):
+
+
+ def __mul__(self, rhs):
print 'called __mul__'
- if isinstance(rhs, oofun):
- return oofun(self.x * rhs.x)
- else:
+ if isinstance(rhs, adouble):
+ print 'case adouble'
+ return adouble(self.x * rhs.x)
+ elif numpy.isscalar(rhs):
+ print 'case scalar'
+ return adouble(self.x * rhs)
+ elif isinstance(rhs, numpy.ndarray):
+ print 'case ndarray'
return rhs * self
- def __rmul__(self, lhs):
+ def __rmul__(self, lhs):
print 'called __rmul__'
- return oofun(self.x * lhs)
-
- def __str__(self):
+ return self * lhs
+
+ def __str__(self):
return str(self.x)+'a'
-
- def __repr__(self):
+
+ def __repr__(self):
return str(self)
-def test_numpy_array_imul_operations():
-
- x = numpy.ones(1)
- y = 1.
- b = oofun(2)
- x *= b
- y *= b
-
-
-
- print x,y
+print 'numpy.__version__=',numpy.__version__,'\n'
+
+x = numpy.ones(2,dtype=float)
+z = numpy.ones(2,dtype=float)
+y = numpy.ones(2,dtype=object)
+
+
+a = adouble(2)
+
+print 'executing a *= x'
+a *= x
+print a,' where expected [2.0a, 2.0a]\n'
+print 'executing y *= a'
+y *= a
+print y,' where expected [2.0a, 2.0a]\n'
+print 'executing z = z * a'
+z = z * a
+print z,' where expected [2.0a, 2.0a]\n'
+print 'executing x *= a'
+x *= a
+print x,' where expected [2.0a, 2.0a]\n'
-if __name__ == '__main__':
- try:
- import nose
- except:
- print 'Please install nose for unit testing'
- nose.runmodule()

0 comments on commit cbd38f8

Please sign in to comment.