Error when testing SciPy

后端 未结 1 1683
星月不相逢
星月不相逢 2020-12-18 04:08

When testing scipy using the nose package using scipy.test(), the test fails under Ubuntu 12.04 with all the vanilla packages installed. Do I have to worry, and

相关标签:
1条回答
  • 2020-12-18 04:42

    If you take a look inside /usr/lib/python2.7/dist-packages/scipy/ndimage/tests/test_io.py you should see:

    def test_imread():
        lp = os.path.join(os.path.dirname(__file__), 'dots.png')
        img = ndi.imread(lp)
        assert_array_equal(img.shape, (300, 420, 3))
    
        img = ndi.imread(lp, flatten=True)
        assert_array_equal(img.shape, (300, 420))
    

    This test seems to be testing if flatten=True converts an RGB image into a 1-bit greyscale image.

    On my Ubuntu 11.10 system, however, dots.png is already a 1-bit image file:

    % file /usr/share/pyshared/scipy/ndimage/tests/dots.png
    /usr/share/pyshared/scipy/ndimage/tests/dots.png: PNG image data, 420 x 300, 1-bit colormap, non-interlaced
    

    If I perform the test (manually) on a RGBA image, then the test works:

    In [18]: z = ndi.imread('image.png')
    
    In [20]: z.shape
    Out[20]: (250, 250, 4)
    
    In [24]: w = ndi.imread('image.png', flatten = True)
    
    In [25]: w.shape
    Out[25]: (250, 250)
    

    So I don't think there is anything seriously wrong here, just that perhaps the dots.png file that was shipped should have been an RGB image instead of a greyscale one.

    0 讨论(0)
提交回复
热议问题