# numpy 2.5.4 (BSD-3-Clause), harvested by tools/harvest_corpus.py
=== input

    can_cast(from_, to, casting='safe')

    Returns True if cast between data types can occur according to the
    casting rule.

    Parameters
    ----------
    from_ : dtype, dtype specifier, NumPy scalar, or array
        Data type, NumPy scalar, or array to cast from.
    to : dtype or dtype specifier
        Data type to cast to.
    casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
        Controls what kind of data casting may occur.

        * 'no' means the data types should not be cast at all.
        * 'equiv' means only byte-order changes are allowed.
        * 'safe' means only casts which can preserve values are allowed.
        * 'same_kind' means only safe casts or casts within a kind,
          like float64 to float32, are allowed.
        * 'unsafe' means any data conversions may be done.

    Returns
    -------
    out : bool
        True if cast can occur according to the casting rule.

    Notes
    -----
    .. versionchanged:: 2.0
       This function does not support Python scalars anymore and does not
       apply any value-based logic for 0-D arrays and NumPy scalars.

    See also
    --------
    dtype, result_type

    Examples
    --------
    Basic examples

    >>> import numpy as np
    >>> np.can_cast(np.int32, np.int64)
    True
    >>> np.can_cast(np.float64, complex)
    True
    >>> np.can_cast(complex, float)
    False

    >>> np.can_cast('i8', 'f8')
    True
    >>> np.can_cast('i8', 'f4')
    False
    >>> np.can_cast('i4', 'S4')
    False

    
=== parse numpydoc
short_description: "can_cast(from_, to, casting='safe')"
long_description: |
  Returns True if cast between data types can occur according to the
  casting rule.
blank_after_short_description: True
blank_after_long_description: True
style: numpydoc
- DocstringParam
  description: 'Data type, NumPy scalar, or array to cast from.'
  kind: param
  key: 'param'
  arg_name: 'from_'
  type_name: 'dtype, dtype specifier, NumPy scalar, or array'
  is_optional: False
- DocstringParam
  description: 'Data type to cast to.'
  kind: param
  key: 'param'
  arg_name: 'to'
  type_name: 'dtype or dtype specifier'
  is_optional: False
- DocstringParam
  description: |
    Controls what kind of data casting may occur.
    
    * 'no' means the data types should not be cast at all.
    * 'equiv' means only byte-order changes are allowed.
    * 'safe' means only casts which can preserve values are allowed.
    * 'same_kind' means only safe casts or casts within a kind,
      like float64 to float32, are allowed.
    * 'unsafe' means any data conversions may be done.
  kind: param
  key: 'param'
  arg_name: 'casting'
  type_name: "{'no', 'equiv', 'safe', 'same_kind', 'unsafe'}"
  is_optional: True
  raw_type_name: "{'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional"
- DocstringReturns
  description: 'True if cast can occur according to the casting rule.'
  kind: returns
  key: 'returns'
  type_name: 'bool'
  is_generator: False
  return_name: 'out'
- DocstringMeta
  description: |
    .. versionchanged:: 2.0
       This function does not support Python scalars anymore and does not
       apply any value-based logic for 0-D arrays and NumPy scalars.
  kind: text
  key: 'notes'
  title: 'Notes'
- DocstringMeta
  description: 'dtype, result_type'
  kind: text
  key: 'see_also'
  title: 'See Also'
- DocstringExample
  description: 'Basic examples'
  kind: examples
  key: 'examples'
  snippet: '>>> import numpy as np'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> np.can_cast(np.int32, np.int64)
    True
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> np.can_cast(np.float64, complex)
    True
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> np.can_cast(complex, float)
    False
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> np.can_cast('i8', 'f8')
    True
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> np.can_cast('i8', 'f4')
    False
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> np.can_cast('i4', 'S4')
    False
=== detect
numpydoc
=== compose numpydoc
can_cast(from_, to, casting='safe')

Returns True if cast between data types can occur according to the
casting rule.

Parameters
----------
from_ : dtype, dtype specifier, NumPy scalar, or array
    Data type, NumPy scalar, or array to cast from.
to : dtype or dtype specifier
    Data type to cast to.
casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional
    Controls what kind of data casting may occur.

    * 'no' means the data types should not be cast at all.
    * 'equiv' means only byte-order changes are allowed.
    * 'safe' means only casts which can preserve values are allowed.
    * 'same_kind' means only safe casts or casts within a kind,
      like float64 to float32, are allowed.
    * 'unsafe' means any data conversions may be done.

Returns
-------
out : bool
    True if cast can occur according to the casting rule.

Notes
-----
.. versionchanged:: 2.0
   This function does not support Python scalars anymore and does not
   apply any value-based logic for 0-D arrays and NumPy scalars.

See Also
--------
dtype, result_type

Examples
--------
Basic examples

>>> import numpy as np
>>> np.can_cast(np.int32, np.int64)
True
>>> np.can_cast(np.float64, complex)
True
>>> np.can_cast(complex, float)
False
>>> np.can_cast('i8', 'f8')
True
>>> np.can_cast('i8', 'f4')
False
>>> np.can_cast('i4', 'S4')
False
