exists#
- ivy.exists(x, /)[source]#
Check as to whether the input is None or not.
- Parameters:
x (
Any) – Input to check.- Return type:
bool- Returns:
ret – True if x is not None, else False.
Examples
With
Anyinput:>>> x = None >>> y = ivy.exists(x) >>> print(y) False
>>> x = "" >>> y = ivy.exists(x) >>> print(y) True
>>> x = [] >>> y = ivy.exists(x) >>> print(y) True
>>> x = 1 >>> y = ivy.exists(x) >>> print(y) True
>>> x = "abc" >>> y = ivy.exists(x) >>> print(y) True
>>> x = [1, 0, -1, 1] >>> y = ivy.exists(x) >>> print(y) True
>>> x = ivy.array([1, 2, 3, 1.2]) >>> y = ivy.exists(x) >>> print(y) True
With a mix of
ivy.ContainerandAnyinput:>>> x = ivy.Container(a=None, b=None) >>> y = ivy.exists(x) >>> print(y) True
>>> x = ivy.Container(a=None, b="") >>> y = ivy.exists(x) >>> print(y) True
>>> x = ivy.Container(a=123, b="") >>> y = ivy.exists(x) >>> print(y) True
- Array.exists(self, /)[source]#
ivy.Array instance method variant of ivy.exists. This method simply wraps the function, and so the docstring for ivy.exists also applies to this method with minimal changes.
- Parameters:
self (
Array) – input array.- Return type:
bool- Returns:
ret – True if input is not None, else False.
Examples
>>> x = ivy.array([1, 2, 3, 1.2]) >>> y = x.exists() >>> print(y) True
>>> x = ivy.array([]) >>> y = x.exists() >>> print(y) True
- Container.exists(self, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#
ivy.Container instance method variant of ivy.exists. This method simply wraps the function, and so the docstring for ivy.exists also applies to this method with minimal changes.
- Parameters:
self (
Container) – The input container.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.
- Return type:
Container- Returns:
ret – A boolean container detailing if any of the leaf nodes are None. True if not None, False if None.
Examples
>>> x = ivy.Container(a=[1,2,3,4], b=[]) >>> y = x.exists() >>> print(y) { a: True, b: True }
>>> x = ivy.Container(a=None, b=[1,2]) >>> y = x.exists() >>> print(y) { a: False, b: True }
>>> x = ivy.Container(a={"d": 1, "c": 3}, b=None) >>> y = x.exists() >>> print(y) { a: { c: True, d: True }, b: False }