Hi Stéfan,

I am sending you this off list.

I just tried scikits.image from git on Windows. The attached patch fixes some minor build and test issues.

Scikits.image.io occasionally seems to shadow Python's io module such that `import gzip` fails. There are 5 test failures like this:

======================================================================
ERROR: test_selem.TestSElem.test_selem_disk
----------------------------------------------------------------------
Traceback (most recent call last):
  File "X:\Python27\lib\site-packages\nose\case.py", line 187, in runTest
    self.test(*self.arg)
File "X:\Python27\lib\site-packages\scikits\image\morphology\tests\test_selem.py", line 39, in test_selem_disk
    self.strel_worker("disk-matlab-output.npy", selem.disk)
File "X:\Python27\lib\site-packages\scikits\image\morphology\tests\test_selem.py", line 29, in strel_worker
    matlab_masks = np.load(os.path.join(data_dir, fn))
File "X:\Python27\lib\site-packages\numpy\lib\npyio.py", line 316, in load
    import gzip
  File "X:\Python27\lib\gzip.py", line 36, in <module>
    class GzipFile(io.BufferedIOBase):
AttributeError: 'module' object has no attribute 'BufferedIOBase'


Christoph


On 3/13/2011 8:19 AM, Stéfan van der Walt wrote:
On Sat, Mar 12, 2011 at 2:35 PM, Zachary Pincus<zachary.pin...@yale.edu>  wrote:
Here's a ctypes interface to FreeImage that I wrote a while back and
was since cleaned up (and maintained) by the scikits.image folk:

https://github.com/stefanv/scikits.image/blob/master/scikits/image/io/_plugins/freeimage_plugin.py

If it doesn't work out of the box on python 3, then it should be
pretty simple to fix.

I now fixed the scikits.image build process under Python 3, so this
should be easy to try out.

Regards
Stéfan
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


diff --git a/scikits/image/_build.py b/scikits/image/_build.py
index eb56edf..94f37d6 100644
--- a/scikits/image/_build.py
+++ b/scikits/image/_build.py
@@ -1,3 +1,4 @@
+import sys
 import os
 import shutil
 import hashlib
@@ -69,10 +70,10 @@ def same_cython(f0, f1):
     if not (os.path.isfile(f0) and os.path.isfile(f1)):
         return False
 
-    f0 = file(f0)
+    f0 = open(f0, 'rb')
     f0.readline()
 
-    f1 = file(f1)
+    f1 = open(f1, 'rb')
     f1.readline()
 
     return md5sum(f0) == md5sum(f1)
diff --git a/scikits/image/io/_plugins/freeimage_plugin.py 
b/scikits/image/io/_plugins/freeimage_plugin.py
index 495c75e..0a1ff89 100644
--- a/scikits/image/io/_plugins/freeimage_plugin.py
+++ b/scikits/image/io/_plugins/freeimage_plugin.py
@@ -36,7 +36,7 @@ def register_api(lib,api):
 
 _FI = None
 for d in lib_dirs:
-    for libname in ('libfreeimage', 'libFreeImage'):
+    for libname in ('FreeImage.dll', 'libfreeimage', 'libFreeImage'):
         try:
             _FI = numpy.ctypeslib.load_library(libname, d)
         except OSError:
diff --git a/scikits/image/io/tests/test_pil.py 
b/scikits/image/io/tests/test_pil.py
index 311cb2b..501355d 100644
--- a/scikits/image/io/tests/test_pil.py
+++ b/scikits/image/io/tests/test_pil.py
@@ -35,9 +35,10 @@ def test_palette_is_gray():
 class TestSave:
     def roundtrip(self, dtype, x, scaling=1):
         f = NamedTemporaryFile(suffix='.png')
-        imsave(f.name, x)
-        f.seek(0)
-        y = imread(f.name)
+        fname = f.name
+        f.close()
+        imsave(fname, x)
+        y = imread(fname)
 
         assert_array_almost_equal((x * scaling).astype(np.int32), y)
 
diff --git a/scikits/image/io/tests/test_sift.py 
b/scikits/image/io/tests/test_sift.py
index f559cfa..5b9a249 100644
--- a/scikits/image/io/tests/test_sift.py
+++ b/scikits/image/io/tests/test_sift.py
@@ -8,7 +8,10 @@ from scikits.image.io import load_sift, load_surf
 
 def test_load_sift():
     f = TemporaryFile()
-    f.write('''2 128
+    fname = f.name
+    f.close()
+    f = open(fname, 'wb')
+    f.write(b'''2 128
 133.92 135.88 14.38 -2.732
 3 12 23 38 10 15 78 20 39 67 42 8 12 8 39 35 118 43 17 0
 0 1 12 109 9 2 6 0 0 21 46 22 14 18 51 19 5 9 41 52
@@ -25,7 +28,8 @@ def test_load_sift():
 51 11 0 20 93 6 0 20 109 57 3 4 5 0 0 28 21 2 0 5
 13 12 75 119 35 0 0 13 28 14 37 121 12 0 0 21 46 5 11 93
 29 0 0 3 14 4 11 99''')
-    f.seek(0)
+    f.close()
+    f = open(fname, 'rb')
     features = load_sift(f)
     f.close()
 
@@ -36,11 +40,15 @@ def test_load_sift():
 
 def test_load_surf():
     f = TemporaryFile()
-    f.write('''65
+    fname = f.name
+    f.close()
+    f = open(fname, 'wb')
+    f.write(b'''65
 2
 38.3727 62.0491 0.0371343 0 0.0371343 -1 -0.0705589 0.0130983 -0.00460534 
0.132168 -0.0718833 0.0320583 -0.0134032 0.0988654 -0.0542241 0.0171002 
-0.00135754 0.105755 -0.0362088 0.0151748 -0.00694272 0.0610017 -0.247091 
0.109605 -0.0337623 0.0813307 -0.24185 0.278548 -0.0494523 0.107804 -0.166312 
0.0691584 -0.0288199 0.138476 -0.110956 0.0280772 -0.0752509 0.0736344 -0.22667 
0.164226 -0.0544717 0.0388139 -0.30194 0.33065 -0.0537507 0.0596398 -0.245395 
0.110925 -0.0603322 0.0239389 -0.18726 0.0374145 -0.0355872 0.0140762 -0.129022 
0.135104 -0.0703396 0.0374049 -0.24256 0.222544 -0.0536354 0.0501252 -0.209004 
0.0971316 -0.0550094 0.0229767 -0.125547 0.0317879 -0.0291574 0.0124569
 68.5773 61.474 0.0313267 0 0.0313267 1 -0.10198 0.130987 -0.0321845 0.0487543 
-0.0900435 0.121113 -0.100917 0.0444702 -0.0151742 0.107604 -0.0542035 0.014069 
-0.00594097 0.0339933 -0.00994295 0.0127262 -0.125613 0.192551 -0.0174399 
0.0433488 -0.272698 0.164641 -0.0676735 0.0467444 -0.0527907 0.258005 
-0.0818114 0.0440569 -0.0104433 0.0548934 -0.0323454 0.0145296 -0.112357 
0.199223 -0.0532903 0.0332622 -0.342481 0.207469 -0.0526129 0.0741355 -0.256234 
0.402708 -0.108296 0.117362 -0.0560274 0.128856 -0.123509 0.0510046 -0.0198793 
0.0775934 -0.103863 0.00406679 -0.10264 0.1312 -0.108244 0.0812913 -0.127868 
0.182924 -0.0680942 0.071913 -0.0858004 0.144806 -0.0176522 0.0686146''')
-    f.seek(0)
+    f.close()
+    f = open(fname, 'rb')
     features = load_surf(f)
     f.close()
 
diff --git a/scikits/image/morphology/tests/test_selem.py 
b/scikits/image/morphology/tests/test_selem.py
index 8bf5898..8ff9318 100644
--- a/scikits/image/morphology/tests/test_selem.py
+++ b/scikits/image/morphology/tests/test_selem.py
@@ -13,14 +13,14 @@ from scikits.image.morphology import *
 class TestSElem():
 
     def test_square_selem(self):
-        for k in xrange(0, 5):
+        for k in range(0, 5):
             actual_mask = selem.square(k)
             expected_mask = np.ones((k, k), dtype='uint8')
             assert_equal(expected_mask, actual_mask)
 
     def test_rectangle_selem(self):
-        for i in xrange(0, 5):
-            for j in xrange(0, 5):
+        for i in range(0, 5):
+            for j in range(0, 5):
                 actual_mask = selem.rectangle(i, j)
                 expected_mask = np.ones((i, j), dtype='uint8')
                 assert_equal(expected_mask, actual_mask)
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to