Skip to content

lmlib.utils.check

Functions:

Functions

is_2dim

is_2dim(arr)
Source code in lmlib/utils/check.py
def is_2dim(arr): return True if np.ndim(arr) == 2 else False

is_1dim

is_1dim(arr)
Source code in lmlib/utils/check.py
def is_1dim(arr): return True if np.ndim(arr) == 1 else False

is_square

is_square(arr)
Source code in lmlib/utils/check.py
def is_square(arr):
    if not is_2dim(arr):
        return False
    return True if np.diff(np.shape(arr)) == 0 else False

is_array_like

is_array_like(arr)
Source code in lmlib/utils/check.py
def is_array_like(arr):
    return isinstance(arr, (list, tuple, np.ndarray))

info_str_found_shape

info_str_found_shape(arr)
Source code in lmlib/utils/check.py
def info_str_found_shape(arr):
    return f'found shape: {np.shape(arr)}'

is_string

is_string(s)
Source code in lmlib/utils/check.py
def is_string(s):
    return isinstance(s, str)

info_str_found_type

info_str_found_type(s)
Source code in lmlib/utils/check.py
def info_str_found_type(s):
    return f'found type: {type(s)}'

deprecated

deprecated(func)

This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.

Source code in lmlib/utils/check.py
def deprecated(func):
    """This is a decorator which can be used to mark functions
    as deprecated. It will result in a warning being emitted
    when the function is used."""

    @functools.wraps(func)
    def new_func(*args, **kwargs):
        warnings.simplefilter('always', DeprecationWarning)  # turn off filter
        warnings.warn("Call to deprecated function {}.".format(func.__name__),
                      category=DeprecationWarning,
                      stacklevel=2)
        warnings.simplefilter('default', DeprecationWarning)  # reset filter
        return func(*args, **kwargs)

    return new_func