Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 测试SciPy时出错_Python_Scipy - Fatal编程技术网

Python 测试SciPy时出错

Python 测试SciPy时出错,python,scipy,Python,Scipy,当使用nose包使用scipy.test()测试scipy时,在安装了所有香草包的Ubuntu 12.04下,测试失败。我必须担心吗?如果是,我如何解决这个问题 In [8]: scipy.test() Running unit tests for scipy NumPy version 1.5.1 NumPy is installed in /usr/lib/python2.7/dist-packages/numpy SciPy version 0.9.0 SciPy is installed

当使用nose包使用
scipy.test()
测试scipy时,在安装了所有香草包的Ubuntu 12.04下,测试失败。我必须担心吗?如果是,我如何解决这个问题

In [8]: scipy.test()
Running unit tests for scipy
NumPy version 1.5.1
NumPy is installed in /usr/lib/python2.7/dist-packages/numpy
SciPy version 0.9.0
SciPy is installed in /usr/lib/python2.7/dist-packages/scipy
Python version 2.7.2+ (default, Jan 21 2012, 23:31:34) [GCC 4.6.2]
nose version 1.1.2

[................]

======================================================================
FAIL: test_io.test_imread
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/lib/python2.7/dist-packages/numpy/testing/decorators.py", line 146, in skipper_func
    return f(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/scipy/ndimage/tests/test_io.py", line 16, in test_imread
    assert_array_equal(img.shape, (300, 420, 3))
  File "/usr/lib/python2.7/dist-packages/numpy/testing/utils.py", line 686, in assert_array_equal
    verbose=verbose, header='Arrays are not equal')
  File "/usr/lib/python2.7/dist-packages/numpy/testing/utils.py", line 579, in assert_array_compare
    raise AssertionError(msg)
AssertionError: 
Arrays are not equal

(shapes (2,), (3,) mismatch)
 x: array([300, 420])
 y: array([300, 420,   3])

----------------------------------------------------------------------
Ran 3780 tests in 32.328s

FAILED (KNOWNFAIL=11, SKIP=20, failures=1)

如果您查看
/usr/lib/python2.7/dist packages/scipy/ndimage/tests/test_io.py
内部,您应该会看到:

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))
此测试似乎是测试
flatte=True
是否将RGB图像转换为1位灰度图像

然而,在我的Ubuntu 11.10系统上,dots.png已经是一个1位图像文件:

% 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
如果我(手动)在RGBA图像上执行测试,则测试有效:

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)
因此,我不认为这里有什么严重的错误,只是装运的
dots.png
文件应该是RGB图像,而不是灰度图像