File: test_io.py

package info (click to toggle)
python-scipy 0.14.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 52,228 kB
  • ctags: 63,719
  • sloc: python: 112,726; fortran: 88,685; cpp: 86,979; ansic: 85,860; makefile: 530; sh: 236
file content (30 lines) | stat: -rw-r--r-- 789 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from __future__ import division, print_function, absolute_import

from numpy.testing import assert_array_equal, dec, run_module_suite
import scipy.ndimage as ndi

import os

try:
    from PIL import Image
    pil_missing = False
except ImportError:
    pil_missing = True


@dec.skipif(pil_missing, msg="The Python Image Library could not be found.")
def test_imread():
    lp = os.path.join(os.path.dirname(__file__), 'dots.png')
    img = ndi.imread(lp, mode="RGB")
    assert_array_equal(img.shape, (300, 420, 3))

    img = ndi.imread(lp, flatten=True)
    assert_array_equal(img.shape, (300, 420))
    
    with open(lp, 'rb') as fobj:
        img = ndi.imread(fobj, mode="RGB")
        assert_array_equal(img.shape, (300, 420, 3))


if __name__ == "__main__":
    run_module_suite()