is_array#

ivy.is_array(x, /, *, exclusive=False)[source]#

Determine whether the input x is either an Ivy Array or a Native Array.

Parameters:
  • x (Any) – The input to check

  • exclusive (bool, default: False) – Whether to check if the data type is exclusively an array, rather than a variable or traced array.

Return type:

bool

Returns:

ret – Boolean, whether or not x is an array.

Examples

>>> x = ivy.array([0, 1, 2])
>>> print(ivy.is_array(x))
True
>>> x = ivy.native_array([9.1, -8.3, 2.8, 3.0])
>>> print(ivy.is_array(x, exclusive=True))
True
>>> x = [2, 3]
>>> print(ivy.is_array(x))
False
Array.is_array(self, /, *, exclusive=False)[source]#

ivy.Array instance method variant of ivy.is_array. This method simply wraps the function, and so the docstring for ivy.is_array also applies to this method with minimal changes.

Parameters:
  • self (Array) – The input to check

  • exclusive (bool, default: False) – Whether to check if the data type is exclusively an array, rather than a variable or traced array.

Return type:

bool

Returns:

ret – Boolean, whether or not x is an array.

Examples

>>> x = ivy.array([0, 1, 2])
>>> print(x.is_array())
True
Container.is_array(self, /, *, exclusive=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container instance method variant of ivy.is_array. This method simply wraps the function, and so the docstring for ivy.is_array also applies to this method with minimal changes.

Parameters:
  • self (Container) – The input to check

  • exclusive (Union[bool, Container], default: False) – Whether to check if the data type is exclusively an array, rather than a variable or traced array.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

Return type:

Container

Returns:

ret – Boolean, whether or not x is an array.

Examples

>>> x = ivy.Container(a=ivy.array([1]), b=ivy.native_array([2, 3]))
>>> y = x.is_array()
>>> print(y)
{
    a: True,
    b: True
}