is_subplots#

paramcheckup.types.is_subplots(value, param_name, kind, kind_name, stacklevel=4, error=True)[source]#

This function checks whether a variable value is of the matplotlib.axes.SubplotBase type.

Parameters:
valueany type

The variable that is tested as being of type matplotlib.axes.SubplotBase ;

param_namestr

The name of the parameter that received the variable value;

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 variable value IS of the matplotlib.axes.SubplotBase type;

raisesTypeError

If variable value is NOT of the matplotlib.axes.SubplotBase type;

Examples

>>> from paramcheckup import types
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> output = types.is_subplots(
    value=ax,
    param_name="axes",
    kind="function",
    kind_name="plot",
    stacklevel=3,
    error=True,
)
>>> plt.close()
>>> print(output)
True
>>> from paramcheckup import types
>>> import matplotlib.pyplot as plt
>>> fig, ax = plt.subplots()
>>> output = types.is_subplots(
    value=fig,
    param_name="axes",
    kind="function",
    kind_name="plot",
    stacklevel=3,
    error=False,
)
UserWarning at line 4: The parameter `axes` in function `plot` must be of type `matplotlib.axes.SubplotBase`, but its type is `Figure`.