matching_size#
- paramcheckup.numpy_arrays.matching_size(arrays, param_names, kind, kind_name, stacklevel=4, error=True)[source]#
This function checks if the size of multiple arrays are equal;
- Parameters:
- arrayslist of one dimension numpy array;
A list of one dimension numpy array that must have the same size;
- param_nameslist of str
A list with the name of each parameter that received the arrays contained in arrays
- 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 the size of all arrays are the same;
- ValueError
If at least one array has a different size than the others;
Examples
>>> from paramcheckup import numpy_arrays >>> import numpy as np >>> x_data = np.array([1, 2, 3, 4, 5, 6]) >>> z_data = np.array([1, 4, 9, 16, 25, 36]) >>> output = numpy_arrays.matching_size( arrays=[x_data, z_data], param_names=["concentration", "absorbance"], kind="function", kind_name="calibration", stacklevel=3, error=False, ) >>> print(output) True
>>> from paramcheckup import numpy_arrays >>> import numpy as np >>> x_data = np.array([1, 2, 3, 4, 5, 6]) >>> y_data = np.array([1, 4, 9, 16, 25,]) >>> z_data = np.array([1, 4, 9, 16, 25, 36]) >>> output = numpy_arrays.matching_size( arrays=[x_data, y_data, z_data], param_names=["x_data", "y_data", "z_data"], kind="function", kind_name="Tukey", stacklevel=3, error=False, ) UserWarning at line 6: The arrays `x_data` and `y_data` and `z_data` in function `Tukey` must have the same size, but at least one of them has a different size than the others. --> x_data = 6 --> y_data = 5 --> z_data = 6