<commit_before>"""
Functions for geometrical image transformation and warping.
"""

from __future__ import absolute_import

import warnings

import numpy as np
import scipy.ndimage.interpolation
try:
    import skimage.transform
    scikit_image_not_found = False
except ImportError:  # pragma: no cover
    scikit_image_not_found = True  # pragma: no cover

__all__ = ['affine_transform']

def affine_transform(image, rmatrix, order=3, scale=1.0, image_center=None,
                     recenter=False, missing=0.0, use_scipy=False):
    """
    Rotates, shifts and scales an image using :func:`skimage.transform.warp`, or
    :func:`scipy.ndimage.interpolation.affine_transform` if specified. Falls back to
    the scipy function if scikit-image can't be imported.

    Parameters
    ----------
    image : ndarray
        2D Image to be rotated.
    rmatrix : 2x2
        Linear transformation rotation matrix.
    order : int 0-5
        Interpolation order to be used. When using scikit-image this parameter
        is passed into :func:`skimage.transform.warp` (e.g., 3 corresponds to
        bi-cubic interpolation).
        When using scipy it is passed into
        :func:`scipy.ndimage.interpolation.affine_transform` where it controls
        the order of the spline.
        Default: 3
    scale : float
        A scale factor for the image. Default is no scaling.
    image_center : tuple
        The point in the image to rotate around (axis of rotation).
        Default: center of the array.<commit_msg>Warning on failed skimage import<commit_after>"""
Functions for geometrical image transformation and warping.
"""

from __future__ import absolute_import

import warnings

import numpy as np
import scipy.ndimage.interpolation
try:
    import skimage.transform
    scikit_image_not_found = False
except ImportError:  # pragma: no cover
    warnings.warn("scikit-image could not be imported. Map rotation will use scipy",
                  ImportWarning)
    scikit_image_not_found = True  # pragma: no cover

__all__ = ['affine_transform']

def affine_transform(image, rmatrix, order=3, scale=1.0, image_center=None,
                     recenter=False, missing=0.0, use_scipy=False):
    """
    Rotates, shifts and scales an image using :func:`skimage.transform.warp`, or
    :func:`scipy.ndimage.interpolation.affine_transform` if specified. Falls back to
    the scipy function if scikit-image can't be imported.

    Parameters
    ----------
    image : ndarray
        2D Image to be rotated.
    rmatrix : 2x2
        Linear transformation rotation matrix.
    order : int 0-5
        Interpolation order to be used. When using scikit-image this parameter
        is passed into :func:`skimage.transform.warp` (e.g., 3 corresponds to
        bi-cubic interpolation).
        When using scipy it is passed into
        :func:`scipy.ndimage.interpolation.affine_transform` where it controls
        the order of the spline.
        Default: 3
    scale : float
        A scale factor for the image. Default is no scaling.
    image_center : tuple
        The point in the image to rotate around (axis of rotation).
        Default: center of the array.
{'fraction_non_alphanumeric': 0.07491344035253383, 'fraction_numerical': 0.007554296506137866, 'mean_word_length': 2.8708891595615103, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2326749', 'n_tokens_mistral': 925, 'n_tokens_neox': 904, 'n_words': 322}