Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Jan 30, 2016
1 parent 4f54b9e commit 4b2692b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion skimage/__init__.py
Expand Up @@ -158,7 +158,9 @@ def _raise_build_error(e):


if sys.version.startswith('2.6'):
warnings.warn("Python 2.6 is deprecated and will not be supported in scikit-image 0.13+", stacklevel=2)
msg = ("Python 2.6 is deprecated and will not be supported in"
"scikit-image 0.13+")
warnings.warn(msg, stacklevel=2)


del warnings, functools, osp, imp, sys
8 changes: 5 additions & 3 deletions skimage/_shared/_warnings.py
Expand Up @@ -7,11 +7,13 @@
__all__ = ['all_warnings', 'expected_warnings', 'warn']


def warn(message, **kwargs):
def warn(message, category=None, stacklevel=2):
"""A version of `warnings.warn` with a default stacklevel of 2.
"""
kwargs.setdefault('stacklevel', 2)
warnings.warn(message, **kwargs)
if category is not None:
warnings.warn(message, category=category, stacklevel=stacklevel)
else:
warnings.warn(message, stacklevel=stacklevel)


@contextmanager
Expand Down
6 changes: 3 additions & 3 deletions skimage/measure/_ccomp.pyx
Expand Up @@ -4,7 +4,7 @@
#cython: wraparound=False

import numpy as np
import warnings
from .._shared.utils import warn

cimport numpy as cnp

Expand Down Expand Up @@ -47,9 +47,9 @@ ctypedef struct bginfo:

cdef void get_bginfo(background_val, bginfo *ret) except *:
if background_val is None:
warnings.warn(DeprecationWarning(
warn(DeprecationWarning(
'The default value for `background` will change to 0 in v0.12'
), stacklevel=2)
))
ret.background_val = -1
else:
ret.background_val = background_val
Expand Down
2 changes: 1 addition & 1 deletion skimage/viewer/utils/core.py
Expand Up @@ -8,7 +8,7 @@

if has_qt and 'agg' not in mpl.get_backend().lower():
warn("Recommended matplotlib backend is `Agg` for full "
"skimage.viewer functionality.")
"skimage.viewer functionality.")


__all__ = ['init_qtapp', 'start_qtapp', 'RequiredAttr', 'figimage',
Expand Down

0 comments on commit 4b2692b

Please sign in to comment.