mlnext.utils.truncate#
- mlnext.utils.truncate(*arrays: Tuple[ndarray, ...], axis: int = 0) Iterator[Tuple[ndarray, ...]] [source]#
- Truncates the arrays in each tuple to the minimum length of an array in
the that tuple.
- Parameters:
axis (int) – Axis to of arrays to truncate.
- Yields:
T.Iterator[T.Tuple[np.ndarray, …]] –
- Iterator over tuple of arrays
where each tuple has of arrays has the same length.
Example
>>> arr1 = [np.ones((1, 1)), np.zeros((2, 1))] >>> arr2 = [np.zeros((2, 1)), np.ones((3, 1))] >>> np.hstack(list(mlnext.utils.truncate(*zip(arr1, arr2)))) ([1, 0, 0], [0, 1, 1])