is_numpy#
- paramcheckup.types.is_numpy(value, param_name, kind, kind_name, stacklevel=4, error=True)[source]#
This function checks whether a variable value is of the numpy array type.
- Parameters:
- valueany type
The variable that is tested as being of type numpy array ;
- 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 numpy array type;
- raisesTypeError
If variable value is NOT of the numpy array type;
Examples
>>> from paramcheckup import types >>> import numpy as np >>> output = types.is_numpy( value=np.array([1, 2, 3, 4, 5]), param_name="x_data", kind="function", kind_name="ttest", stacklevel=3, error=True, ) >>> print(output) True
>>> from paramcheckup import types >>> import numpy as np >>> output = types.is_numpy( value=[1, 2, 3, 4, 5], param_name="x_data", kind="function", kind_name="ttest", stacklevel=3, error=False, ) UserWarning at line 3: The parameter `x_data` in function `ttest` must be of type `numpy.ndarray`, but its type is `list`.