is_lower_than#

paramcheckup.numbers.is_lower_than(number, upper, param_name, kind, kind_name, inclusive=True, stacklevel=4, error=True)[source]#

This function checks if a number is equal (open or closed) or lower than upper.

Parameters:
numberint or float

The number that needs to be checked;

upperint or float

The upper bound;

param_namestr

The name of the parameter that received the variable number;

kindstr

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

kind_namestr

The name of the object kind;

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 numer IS lower than upper (or number IS lower/equal than upper);

raisesValueError

If numer is NOT lower than upper (or number is NOT lower/equal than upper);

Examples

>>> from paramcheckup import numbers
>>> output = numbers.is_lower_than(
    number=0.05,
    upper=1,
    param_name="alpha",
    kind="function",
    kind_name="ttest",
    inclusive=True,
    stacklevel=3,
    error=False,
)
>>> print(output)
True
>>> from paramcheckup import numbers
>>> output = numbers.is_lower_than(
    number=1,
    upper=1,
    param_name="alpha",
    kind="function",
    kind_name="ttest",
    inclusive=False,
    stacklevel=3,
    error=False,
)
UserWarning at line 2: The value of `alpha` in function `ttest` must be lower than `1` (`alpha < 1`), but it is `1`.
>>> from paramcheckup import numbers
>>> output = numbers.is_lower_than(
    number=1.05,
    upper=1,
    param_name="alpha",
    kind="function",
    kind_name="ttest",
    inclusive=True,
    stacklevel=3,
    error=False,
)
UserWarning at line 2: The value of `alpha` in function `ttest` must be equal or lower than `1` (`alpha <= 1`), but it is `1.05`.