Beispiel #1
0
def _handle_on_image_shape(shape, obj):
    if hasattr(shape, "shape"):
        ia.warn_deprecated(
            "Providing a numpy array for parameter `shape` in "
            "`%s` is deprecated. Please provide a shape tuple, "
            "i.e. a tuple of integers denoting (height, width, [channels]). "
            "Use something similar to `image.shape` to convert an array "
            "to a shape tuple." % (obj.__class__.__name__, ))
        shape = normalize_shape(shape)
    else:
        assert isinstance(shape, tuple), (
            "Expected to get a tuple of integers or a numpy array "
            "(deprecated) for parameter `shape` in `%s`. Got type %s." %
            (obj.__class__.__name__, type(shape).__name__))
    return shape
Beispiel #2
0
def _normalize_shift_args(x, y, top=None, right=None, bottom=None, left=None):
    """Normalize ``shift()`` arguments to x, y and handle deprecated args."""
    if any([v is not None for v in [top, right, bottom, left]]):
        ia.warn_deprecated(
            "Got one of the arguments `top` (%s), `right` (%s), "
            "`bottom` (%s), `left` (%s) in a shift() call. "
            "These are deprecated. Use `x` and `y` instead." %
            (top, right, bottom, left),
            stacklevel=3)
        top = top if top is not None else 0
        right = right if right is not None else 0
        bottom = bottom if bottom is not None else 0
        left = left if left is not None else 0
        x = x + left - right
        y = y + top - bottom
    return x, y