changeset 782:ba068f7d4d3e

Fixed test_float
author Olivier Delalleau <delallea@iro>
date Fri, 26 Jun 2009 09:55:32 -0400
parents e768674aa51f
children f84e6f301a18
files pylearn/algorithms/sandbox/test_cost.py
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/algorithms/sandbox/test_cost.py	Wed Jun 24 10:53:55 2009 -0400
+++ b/pylearn/algorithms/sandbox/test_cost.py	Fri Jun 26 09:55:32 2009 -0400
@@ -14,13 +14,19 @@
 
     def test_float(self):
         """
-        This should fail because we can't use floats in logfactorial
+        Ensure we cannot use floats in logfactorial.
         """
         x = TT.as_tensor([0.5, 2.7])
         o = cost.logfactorial(x)
-        f = T.function([],o)
-#        print repr(f())
-        self.failUnless(numpy.all(f() == numpy.asarray([0., 0., 1.38629436, 3.29583687, 5.54517744, 8.04718956, 10.75055682, 13.62137104, 16.63553233, 19.7750212])))
+        f = T.function([], o)
+        try:
+            f()
+            assert False
+        except TypeError, e:
+            if str(e).find("<type 'float'>, must be int or long") >= 0:
+                pass
+            else:
+                raise
 
 class T_nlpoisson(unittest.TestCase):
     def test(self):