oki doki -- here is an update -- boiled down all numpy-related issues (I have
not looked at the failing mock-related test -- which smells also like a
regression in mock 0.8.0):

1.
> NB unittests.test_files.test_NumpyBinaryFile failure seems was gone in
> its own course with upgrades of numpy

> but I also started to get 
> ======================================================================
> ERROR: unittests.test_files.test_NumpyBinaryFile
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
>     self.test(*self.arg)
>   File "/tmp/buildd/pynn-0.7.2/test/unittests/test_files.py", line 92, in 
> test_NumpyBinaryFile
>     assert_equal(nbf.get_metadata(), metadata)
>   File 
> "/tmp/buildd/pynn-0.7.2/build/lib.linux-x86_64-2.7/pyNN/recording/files.py", 
> line 216, in get_metadata
>     self.fileobj.seek(0)
> ValueError: I/O operation on closed file

here is the report:
http://projects.scipy.org/numpy/ticket/2178#comment:1
and tentative fix
https://github.com/numpy/numpy/pull/328

pynn "workaround" would probably simply to disable that portions
of the test on numpy >= 1.6, and <= (where gets fixed).

agree?

2.

A new one
======================================================================
FAIL: unittests.test_files.test_StandardTextFile_write
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/home/yoh/deb/gits/pkg-exppsy/pynn/test/unittests/test_files.py", line 
57, in test_StandardTextFile_write
    target)
AssertionError: [call('# a = 1\n# b = 9.99\n'),
 call('0.0\t2.2999999999999998\n'),
 call('1.0\t3.3999999999999999\n'),
 call('2.0\t4.2999999999999998\n')] != [(('# a = 1\n# b = 9.99\n',), {}), 
(('0.0\t2.3\n',), {}), (('1.0\t3.4\n',), {}), (('2.0\t4.3\n',), {})]


which I haven't figured out 100% but 

$> python2.7 -c "print repr([(0, 2.3),(1, 3.4),(2, 4.3)])"                      
                           
[(0, 2.3), (1, 3.4), (2, 4.3)]
$> python2.6 -c "print repr([(0, 2.3),(1, 3.4),(2, 4.3)])" 
[(0, 2.2999999999999998), (1, 3.3999999999999999), (2, 4.2999999999999998)]

suggests that it might be just worth not relying on repr of FPs where
either decimal or binary form aren't unambiguous, so please
find/accept/consider attached patch or advise on the alternative resolution

3.
> ======================================================================
> FAIL: unittests.test_files.test_NumpyBinaryFile
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
>     self.test(*self.arg)
>   File "/«PKGBUILDDIR»/test/unittests/test_files.py", line 92, in 
> test_NumpyBinaryFile
>     assert_equal(nbf.get_metadata(), metadata)
> AssertionError: {'a': 1, 'b': 9} != {'a': 1, 'b': 9.99}
> - {'a': 1, 'b': 9}
> + {'a': 1, 'b': 9.99}
> ?               +++

boiled down once again to numpy's regression (fixed upstream in as bisected
e15d0bdd3cc0bc0928e1f4d0b419a2fb3de02af9)

Debian bug report: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=679948
pynn resolution:  

 is metadata always of 'float' type?  then dtype=(str, float) could be
provided to np.array within NumpyBinaryFile.save  to assure correct dtype... 

 please advise

-- 
Yaroslav O. Halchenko
Postdoctoral Fellow,   Department of Psychological and Brain Sciences
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik        
From 70295461024cc95709ae214b96aa4caa9c225ae9 Mon Sep 17 00:00:00 2001
From: Yaroslav Halchenko <deb...@onerussian.com>
Date: Mon, 2 Jul 2012 11:42:11 -0400
Subject: [PATCH] BF: test_StandardTextFile_write - test on numbers with a
 disambigous binary/decimal repr

---
 test/unittests/test_files.py |   17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/test/unittests/test_files.py b/test/unittests/test_files.py
index da4ebe8..1c937ce 100644
--- a/test/unittests/test_files.py
+++ b/test/unittests/test_files.py
@@ -46,12 +46,21 @@ def test_close():
 def test_StandardTextFile_write():
     files.open = Mock()
     stf = files.StandardTextFile("filename", "w")
-    data=[(0, 2.3),(1, 3.4),(2, 4.3)]
+    # yoh: %r on FP is inconsistent even across Python's versions:
+    # > python-2.7 -c "print repr([(0, 2.3),(1, 3.4),(2, 4.3)])"
+    # [(0, 2.3), (1, 3.4), (2, 4.3)]
+    # > python2.6 -c "print repr([(0, 2.3),(1, 3.4),(2, 4.3)])"
+    # [(0, 2.2999999999999998), (1, 3.3999999999999999), (2, 4.2999999999999998)]
+    # so that makes straightforward comparison with numbers without
+    # exact binary representation weak and leading to spurious
+    # failures.  So testing here basic functioning on numbers with
+    # obvious binary representation
+    data=[(0, 2.25),(1, 3.5),(2, 4.125)]
     metadata = {'a': 1, 'b': 9.99}
     target = [(('# a = 1\n# b = 9.99\n',), {}),
-              (('0.0\t2.3\n',), {}),
-              (('1.0\t3.4\n',), {}),
-              (('2.0\t4.3\n',), {})]
+              (('0.0\t2.25\n',), {}),
+              (('1.0\t3.5\n',), {}),
+              (('2.0\t4.125\n',), {})]
     stf.write(data, metadata)
     assert_equal(stf.fileobj.write.call_args_list,
                  target)
-- 
1.7.10

Reply via email to