watex.utils.reshape#
- watex.utils.reshape(arr, axis=None)[source]#
Detect the array shape and reshape it accordingly, back to the given axis.
- Parameters
array – array_like with number of dimension equals to 1 or 2
axis – axis to reshape back array. If ‘axis’ is None and the number of dimension is greater than 1, it reshapes back array to array-like
- Returns
New reshaped array
- Example
>>> import numpy as np >>> from watex.utils.funcutils import reshape >>> array = np.random.randn(50 ) >>> array.shape ... (50,) >>> ar1 = reshape(array, 1) >>> ar1.shape ... (1, 50) >>> ar2 =reshape(ar1 , 0) >>> ar2.shape ... (50, 1) >>> ar3 = reshape(ar2, axis = None) >>> ar3.shape # goes back to the original array >>> ar3.shape ... (50,)