mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-14 12:50:39 +08:00
Removed obsolete Image class from io submodule.
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
from io import BytesIO
|
||||
|
||||
import numpy as np
|
||||
from skimage import img_as_ubyte
|
||||
from skimage.io import Image, imread
|
||||
|
||||
from numpy.testing import assert_equal, assert_array_equal
|
||||
|
||||
|
||||
def test_tags():
|
||||
f = Image([1, 2, 3], foo='bar', sigma='delta')
|
||||
g = Image([3, 2, 1], sun='moon')
|
||||
h = Image([1, 1, 1])
|
||||
|
||||
assert_equal(f.tags['foo'], 'bar')
|
||||
assert_array_equal((g + 2).tags['sun'], 'moon')
|
||||
assert_equal(h.tags, {})
|
||||
|
||||
|
||||
def test_repr_png_roundtrip():
|
||||
# Use RGB-like shape since some backends convert grayscale to RGB
|
||||
original_array = 255 * np.ones((5, 5, 3), dtype=np.uint8)
|
||||
image = Image(original_array)
|
||||
array = imread(BytesIO(image._repr_png_()))
|
||||
# Force output to ubyte range for plugin compatibility.
|
||||
# For example, Matplotlib will return floats even if the image is uint8.
|
||||
assert_array_equal(img_as_ubyte(array), original_array)
|
||||
# Note that PIL breaks with `_repr_jpeg_`.
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from numpy.testing import run_module_suite
|
||||
run_module_suite()
|
||||
@@ -7,8 +7,7 @@ from numpy.testing import (
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
from ... import data_dir
|
||||
from .. import (imread, imsave, use_plugin, reset_plugins,
|
||||
Image as ioImage)
|
||||
from .. import imread, imsave, use_plugin, reset_plugins
|
||||
from ..._shared.testing import mono_check, color_check
|
||||
from ..._shared._warnings import expected_warnings
|
||||
from ..._shared._tempfile import temporary_file
|
||||
@@ -80,19 +79,6 @@ def test_imread_uint16():
|
||||
assert_array_almost_equal(img, expected)
|
||||
|
||||
|
||||
def test_repr_png():
|
||||
img_path = os.path.join(data_dir, 'camera.png')
|
||||
original_img = ioImage(imread(img_path))
|
||||
original_img_str = original_img._repr_png_()
|
||||
|
||||
with NamedTemporaryFile(suffix='.png') as temp_png:
|
||||
temp_png.write(original_img_str)
|
||||
temp_png.seek(0)
|
||||
round_trip = imread(temp_png)
|
||||
|
||||
assert np.all(original_img == round_trip)
|
||||
|
||||
|
||||
def test_imread_truncated_jpg():
|
||||
assert_raises((IOError, ValueError), imread,
|
||||
os.path.join(data_dir, 'truncated.jpg'))
|
||||
|
||||
Reference in New Issue
Block a user