is_negative#

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

This function checks whether number is a negative number (lower than zero, not included).

Parameters:
numberint or float

The number that needs to be checked;

param_namestr

The name of the parameter that received the variable

kindstr

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

kind_namestr

The name of the object kind;

stacklevelint, optional

The stacking level (default is 4);

errorbool, optional

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

Returns:
outputTrue

If number IS negative;

ValueError

If number is NOT negative;

Examples

>>> from paramcheckup import numbers
>>> result = numbers.is_negative(
    number=-10,
    param_name="hypotenuse",
    kind="function",
    kind_name="pitagoras",
    stacklevel=3,
    error=True,
)
>>> print(result)
True
>>> from paramcheckup import numbers
>>> result = numbers.is_negative(
    number=0,
    param_name="hypotenuse",
    kind="function",
    kind_name="pitagoras",
    stacklevel=3,
    error=False,
)
UserWarning at line 2: The `hypotenuse` in function `pitagoras` must be a negative number, but it is equal to `0`.
>>> from paramcheckup import numbers
>>> result = numbers.is_negative(
    number=3.1416,
    param_name="hypotenuse",
    kind="function",
    kind_name="pitagoras",
    stacklevel=3,
    error=False,
)
UserWarning at line 2: The `hypotenuse` in function `pitagoras` must be a negative number, but it is equal to `3.1416`.