COO.reshape

COO.reshape(shape)[source]

Returns a new COO array that is a reshaped version of this array.

Parameters:shape (tuple[int]) – The desired shape of the output array.
Returns:The reshaped output array.
Return type:COO

See also

numpy.ndarray.reshape()
The equivalent Numpy function.

Examples

>>> s = COO.from_numpy(np.arange(25))
>>> s2 = s.reshape((5, 5))
>>> s2.todense()  
array([[ 0,  1,  2,  3,  4],
       [ 5,  6,  7,  8,  9],
       [10, 11, 12, 13, 14],
       [15, 16, 17, 18, 19],
       [20, 21, 22, 23, 24]])