cummin#
- ivy.cummin(x, /, *, axis=0, exclusive=False, reverse=False, dtype=None, out=None)[source]#
Return the cumulative minimum of the elements along a given axis.
- Parameters:
x (
Union
[Array
,NativeArray
]) – Input array.axis (
int
, default:0
) – Axis along which the cumulative minimum is computed. Default is0
.reverse (
bool
, default:False
) – Whether to perform the cummin from last to first element in the selected axis. Default isFalse
(from first to last element)dtype (
Optional
[Union
[Dtype
,NativeDtype
]], default:None
) – Data type of the returned array. Default isNone
. If None, if the default data type corresponding to the data type “kind” (integer or floating-point) of x has a smaller range of values than the data type of x (e.g., x has data type int64 and the default data type is int32, or x has data type uint64 and the default data type is int64), the returned array must have the same data type as x. If x has a floating-point data type, the returned array must have the default floating-point data type. If x has a signed integer data type (e.g., int16), the returned array must have the default integer data type. If x has an unsigned integer data type (e.g., uint16), the returned array must have an unsigned integer data type having the same number of bits as the default integer data type (e.g., if the default integer data type is int32, the returned array must have a uint32 data type). If the data type (either specified or resolved) differs from the data type of x, the input array should be cast to the specified data type before computing the product.out (
Optional
[Array
], default:None
) – Optional output array, for writing the result to. It must have a shape that the inputs broadcast to.
- Return type:
- Returns:
ret – Array which holds the result of applying cummin at each original array elements along the specified axis.
Examples
With
ivy.Array
input:>>> x = ivy.array([1, 5, 2, 0]) >>> y = ivy.cummin(x) >>> print(y) ivy.array([1, 1, 1, 0]) >>> x = ivy.array([[6, 4, 2], ... [1, 3, 0]]) >>> y = ivy.zeros((2,3)) >>> ivy.cummin(x, axis=0, reverse=True, out=y) >>> print(y) ivy.array([[1., 3., 0.], [1., 3., 0.]])
>>> x = ivy.array([[2, 4, 5], ... [3, 6, 5], ... [1, 3, 10]]) >>> ivy.cummin(x,axis=1,reverse=True, dtype='int64', out=x) >>> print(x) ivy.array([[ 2, 4, 5], [ 3, 5, 5], [ 1, 3, 10]])
With
ivy.Container
input:>>> x = ivy.Container(a=ivy.array([[1, 3, 5]]), ... b=ivy.array([[3, 5, 7]])) >>> y = ivy.cummin(x, axis= 0) >>> print(y) { a: ivy.array([[1, 3, 5]]), b: ivy.array([[3, 5, 7]]) }
>>> x = ivy.Container(a=ivy.array([[1, 3, 4]]), ... b=ivy.array([[3, 5, 8], ... [5, 6, 5]]), ... c=ivy.array([[2, 4, 1], ... [3, 6, 9], ... [0, 2, 3]])) >>> y = ivy.Container(a = ivy.zeros((1, 3)), ... b = ivy.zeros((2, 3)), ... c = ivy.zeros((3,3))) >>> ivy.cummin(x,axis=1,reverse=True, out=y) >>> print(y) { a: ivy.array([[1., 3., 4.]]), b: ivy.array([[3., 5., 8.], [5., 5., 5.]]), c: ivy.array([[1., 1., 1.], [3., 6., 9.], [0., 2., 3.]]) }
>>> x = ivy.Container(a=ivy.array([[0],[5]]), ... b=ivy.array([[6, 8, 7], ... [4, 2, 3]]), ... c=ivy.array([[1, 2], ... [3, 4], ... [6, 4]])) >>> ivy.cummin(x,axis=0,out=x) >>> print(x) { a: ivy.array([[0], [0]]), b: ivy.array([[6, 8, 7], [4, 2, 3]]), c: ivy.array([[1, 2], [1, 2], [1, 2]]) }
- Array.cummin(self, /, *, axis=0, exclusive=False, reverse=False, dtype=None, out=None)[source]#
ivy.Array instance method variant of ivy.cummin. This method simply wraps the function, and so the docstring for ivy.cummin also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input arrayaxis (
int
, default:0
) – int, axis along which to take the cumulative minimum. Default is0
.reverse (
bool
, default:False
) – Whether to perform the cummin from last to first element in the selected axis. Default isFalse
(from first to last element)dtype (
Optional
[Union
[Dtype
,NativeDtype
]], default:None
) – data type of the returned array. If None, if the default data type corresponding to the data type “kind” (integer or floating-point) of x has a smaller range of values than the data type of x (e.g., x has data type int64 and the default data type is int32, or x has data type uint64 and the default data type is int64), the returned array must have the same data type as x. if x has a floating-point data type, the returned array must have the default floating-point data type. if x has a signed integer data type (e.g., int16), the returned array must have the default integer data type. if x has an unsigned integer data type (e.g., uint16), the returned array must have an unsigned integer data type having the same number of bits as the default integer data type (e.g., if the default integer data type is int32, the returned array must have a uint32 data type). If the data type (either specified or resolved) differs from the data type of x, the input array should be cast to the specified data type before computing the product. Default:None
.out (
Optional
[Array
], default:None
) – optional output array, for writing the result to.
- Return type:
Array
- Returns:
ret – Input array with cumulatively multiplied elements along the specified axis.
——–
>>> x = ivy.array([1, 2, 3, 4, 5])
>>> y = x.cummin()
>>> print(y)
ivy.array([1, 1, 1, 1, 1])
>>> x = ivy.array([[2, 3], [5, 7], [11, 13]])
>>> y = ivy.zeros((3, 2), dtype=”int32”)
>>> x.cummin(axis=1, reverse=True, out=y)
>>> print(y)
ivy.array([[ 2, 3], – [ 5, 7], [11, 13]])
- Container.cummin(self, /, *, axis=0, exclusive=False, reverse=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, dtype=None, out=None)[source]#
ivy.Container instance method variant of ivy.cummin. This method simply wraps the function, and so the docstring for ivy.cummin also applies to this method with minimal changes.
- Parameters:
self (
Container
) – Input container to cummin at leaves.axis (
Union
[int
,Container
], default:0
) – Axis along which the cumulative product is computed. Default is0
.exclusive (
Union
[bool
,Container
], default:False
) – Whether to exclude the first element of the input array. Default isFalse
.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
],Container
]], default:None
) – The key-chains to apply or not apply the method to. Default isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.dtype (
Optional
[Union
[Dtype
,NativeDtype
,Container
]], default:None
) – Data type of the returned array. Default isNone
.out (
Optional
[Container
], default:None
) – Optional output container. Default isNone
.
- Return type:
Container
- Returns:
ret – Containers with arrays cummin at leaves along specified axis.
Examples #TODO (change examples and change doc string)
——–
With one
ivy.Container
instances>>> x = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([4, 5, 6]))
>>> y = x.cummin(axis=0)
>>> print(y)
{ – a: ivy.array([1, 1, 1]), b: ivy.array([4, 4, 4])
}
>>> x = ivy.Container(a=ivy.array([[2, 3], [5, 7], [11, 13]]), – b=ivy.array([[3, 4], [4, 5], [5, 6]]))
>>> y = ivy.Container(a = ivy.zeros((3, 2)), b = ivy.zeros((3, 2)))
>>> x.cummin(axis=1, out=y)
{ –
- a: ivy.array([[2, 2],
[5, 5], [11, 11]]),
- b: ivy.array([[3, 3],
[4, 4], [5, 5]])
}