size_is_greater_than_lower#

paramcheckup.numpy_arrays.size_is_greater_than_lower(array, param_name, kind, kind_name, lower, inclusive=True, stacklevel=4, error=True)[source]#

This function checks if the size of the numpy array array is greater;equal than lower.

Parameters:
arraynumpy array

One dimension numpy array;

param_namestr

The name of the parameter that received the variable array;

kindstr

The object where param_name is applied (function, method, class, etc.);

kind_namestr

The name of the object kind;

lowerint or float

The lower bound;

inclusivebool, optional

Specify whether the boundaries should be open (False) or closed (True, default);

stacklevelint, optional

The stacking level (default is 4);

errorbool, optional

Whether to display error text (True, default) or not (False);

Returns:
outputTrue

If the size of the array IS greater than lower (or IS equal/greater than lower);

raisesValueError

If the size of the array is NOT greater than lower (or is NOT equal/greater than lower);

Examples

>>> from paramcheckup import numpy_arrays
>>> import numpy as np
>>> x_exp = np.array([1, 1, 2, 4, 4, 2, 3])
>>> output = numpy_arrays.size_is_greater_than_lower(
    array=x_exp,
    param_name="x_data",
    kind="function",
    kind_name="linear_regression",
    lower=3,
    inclusive=True,
    stacklevel=3,
    error=True,
)
>>> print(output)
True
>>> from paramcheckup import numpy_arrays
>>> import numpy as np
>>> x_exp = np.array([1, 2, 4])
>>> output = numpy_arrays.size_is_greater_than_lower(
    array=x_exp,
    param_name="x_data",
    kind="function",
    kind_name="linear_regression",
    lower=3,
    inclusive=True,
    stacklevel=3,
    error=True,
)
>>> print(output)
True
>>> from paramcheckup import numpy_arrays
>>> import numpy as np
>>> x_exp = np.array([1, 2])
>>> output = numpy_arrays.size_is_greater_than_lower(
    array=x_exp,
    param_name="x_data",
    kind="function",
    kind_name="linear_regression",
    lower=3,
    inclusive=True,
    stacklevel=3,
    error=False,
)
UserWarning at line 4: The size of the array `x_data` in function `linear_regression` must be equal or greater than `3` (`x_data.size >= 3`), but it is `2`.
>>> from paramcheckup import numpy_arrays
>>> import numpy as np
>>> x_exp = np.array([1, 2, 4])
>>> output = numpy_arrays.size_is_greater_than_lower(
    array=x_exp,
    param_name="x_data",
    kind="function",
    kind_name="linear_regression",
    lower=3,
    inclusive=False,
    stacklevel=3,
    error=False,
)
UserWarning at line 4: The size of the array `x_data` in function `linear_regression` must be greater than `3` (`x_data.size > 3`), but it is `3`.