Skip to content

Commit

Permalink
Use always_warn for low_contrast warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Mar 10, 2015
1 parent 3ae65af commit 59184db
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions skimage/io/_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ..color import rgb2grey
from .util import file_or_url_context
from ..exposure import is_low_contrast
from .._shared._warnings import all_warnings
from .._shared._warnings import always_warn


__all__ = ['Image', 'imread', 'imread_collection', 'imsave', 'imshow', 'show']
Expand Down Expand Up @@ -156,7 +156,8 @@ def imsave(fname, arr, plugin=None, **plugin_args):
"""
if is_low_contrast(arr):
warnings.warn('%s is a low contrast image' % fname)
with always_warn():
warnings.warn('%s is a low contrast image' % fname)
return call_plugin('imsave', fname, arr, plugin=plugin, **plugin_args)


Expand Down
21 changes: 11 additions & 10 deletions skimage/io/_plugins/matplotlib_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import matplotlib.pyplot as plt
from ...util import dtype as dtypes
from ...exposure import is_low_contrast
from ..._shared._warnings import all_warnings
from ..._shared._warnings import always_warn


_default_colormap = 'gray'
Expand Down Expand Up @@ -67,15 +67,16 @@ def _raise_warnings(image_properties):
The properties of the considered image.
"""
ip = image_properties
if ip.unsupported_dtype:
warnings.warn("Non-standard image type; displaying image with "
"stretched contrast.")
if ip.low_dynamic_range:
warnings.warn("Low image dynamic range; displaying image with "
"stretched contrast.")
if ip.out_of_range_float:
warnings.warn("Float image out of standard range; displaying "
"image with stretched contrast.")
with always_warn():
if ip.unsupported_dtype:
warnings.warn("Non-standard image type; displaying image with "
"stretched contrast.")
if ip.low_dynamic_range:
warnings.warn("Low image dynamic range; displaying image with "
"stretched contrast.")
if ip.out_of_range_float:
warnings.warn("Float image out of standard range; displaying "
"image with stretched contrast.")


def _get_display_range(image):
Expand Down

0 comments on commit 59184db

Please sign in to comment.