array_split.split.shape_factors¶
-
array_split.split.
shape_factors
(n, dim=2)[source]¶ Returns a
numpy.ndarray
of factorsf
such that(len(f) == dim) and (numpy.product(f) == n)
. The returned factors are as square (cubic, etc) as possible. For example:>>> shape_factors(24, 1) array([24]) >>> shape_factors(24, 2) array([4, 6]) >>> shape_factors(24, 3) array([2, 3, 4]) >>> shape_factors(24, 4) array([2, 2, 2, 3]) >>> shape_factors(24, 5) array([1, 2, 2, 2, 3]) >>> shape_factors(24, 6) array([1, 1, 2, 2, 2, 3])
Parameters: Return type: Returns: A
(dim,)
shaped array of integers which are factors ofn
.