files: from __future__ import annotations
  
  from ._array_object import Array
  from ._dtypes import _all_dtypes, _result_type
  
  from dataclasses import dataclass
  from typing import TYPE_CHECKING, List, Tuple, Union
  if TYPE_CHECKING:
      from ._typing import Dtype
      from collections.abc import Sequence
  
  import numpy as np
  
  def broadcast_arrays(*arrays: Sequence[Array]) -> List[Array]:
      """
      Array API compatible wrapper for :py:func:`np.broadcast_arrays <numpy.broadcast_arrays>`.
  
      See its docstring for more information.
      """
      from ._array_object import Array
      return [Array._new(array) for array in np.broadcast_arrays(*[a._array for a in arrays])]
  
  def broadcast_to(x: Array, /, shape: Tuple[int, ...]) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.broadcast_to <numpy.broadcast_to>`.
  
      See its docstring for more information.
      """
      from ._array_object import Array
      return Array._new(np.broadcast_to(x._array, shape))
  
  def can_cast(from_: Union[Dtype, Array], to: Dtype, /) -> bool:
      """
      Array API compatible wrapper for :py:func:`np.can_cast <numpy.can_cast>`.
  
      See its docstring for more information.
      """
      from ._array_object import Array
      if isinstance(from_, Array):
          from_ = from_._array
      return np.can_cast(from_, to)
  
  # These are internal objects for the return types of finfo and iinfo, since
  # the NumPy versions contain extra data that isn't part of the spec.
  @dataclass
  class finfo_object:
      bits: int
      # Note: The types of the float data here are float, whereas in NumPy they
      # are scalars of the corresponding float dtype.
      eps: float
      max: float
      min: float
      # Note: smallest_normal is part of the array API spec, but cannot be used
      # until https://github.com/numpy/numpy/pull/18536 is merged.
  
      # smallest_normal: float
  
  @dataclass
  class iinfo_object:
      bits: int
      max: int
      min: int
  
  def finfo(type: Union[Dtype, Array], /) -> finfo_object:
      """
      Array API compatible wrapper for :py:func:`np.finfo <numpy.finfo>`.
  
      See its docstring for more information.
      """
      fi = np.finfo(type)
      # Note: The types of the float data here are float, whereas in NumPy they
      # are scalars of the corresponding float dtype.
      return finfo_object(
          fi.bits,
          float(fi.eps),
          float(fi.max),
          float(fi.min),
          # TODO: Uncomment this when #18536 is merged.
          # float(fi.smallest_normal),
      )
  
  def iinfo(type: Union[Dtype, Array], /) -> iinfo_object:
      """
      Array API compatible wrapper for :py:func:`np.iinfo <numpy.iinfo>`.
  
      See its docstring for more information.
      """
      ii = np.iinfo(type)
      return iinfo_object(ii.bits, ii.max, ii.min)
  
  def result_type(*arrays_and_dtypes: Sequence[Union[Array, Dtype]]) -> Dtype:
      """
      Array API compatible wrapper for :py:func:`np.result_type <numpy.result_type>`.
  
      See its docstring for more information.
      """
      # Note: we use a custom implementation that gives only the type promotions
      # required by the spec rather than using np.result_type. NumPy implements
      # too many extra type promotions like int64 + uint64 -> float64, and does
      # value-based casting on scalar arrays.
      A = []
      for a in arrays_and_dtypes:
          if isinstance(a, Array):
              a = a.dtype
          elif isinstance(a, np.ndarray) or a not in _all_dtypes:
              raise TypeError("result_type() inputs must be array_api arrays or dtypes")
          A.append(a)
  
      if len(A) == 0:
          raise ValueError("at least one array or dtype is required")
      elif len(A) == 1:
          return A[0]
      else:
          t = A[0]
          for t2 in A[1:]:
              t = _result_type(t, t2)
          return t
  
files: numpy/_array_api/_data_type_functions.py
files: from __future__ import annotations
  
  from ._array_object import Array
  from ._dtypes import _all_dtypes
  
  from dataclasses import dataclass
  from typing import TYPE_CHECKING, List, Tuple, Union
  if TYPE_CHECKING:
      from ._typing import Dtype
      from collections.abc import Sequence
  
  import numpy as np
  
  def broadcast_arrays(*arrays: Sequence[Array]) -> List[Array]:
      """
      Array API compatible wrapper for :py:func:`np.broadcast_arrays <numpy.broadcast_arrays>`.
  
      See its docstring for more information.
      """
      from ._array_object import Array
      return [Array._new(array) for array in np.broadcast_arrays(*[a._array for a in arrays])]
  
  def broadcast_to(x: Array, /, shape: Tuple[int, ...]) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.broadcast_to <numpy.broadcast_to>`.
  
      See its docstring for more information.
      """
      from ._array_object import Array
      return Array._new(np.broadcast_to(x._array, shape))
  
  def can_cast(from_: Union[Dtype, Array], to: Dtype, /) -> bool:
      """
      Array API compatible wrapper for :py:func:`np.can_cast <numpy.can_cast>`.
  
      See its docstring for more information.
      """
      from ._array_object import Array
      if isinstance(from_, Array):
          from_ = from_._array
      return np.can_cast(from_, to)
  
  # These are internal objects for the return types of finfo and iinfo, since
  # the NumPy versions contain extra data that isn't part of the spec.
  @dataclass
  class finfo_object:
      bits: int
      # Note: The types of the float data here are float, whereas in NumPy they
      # are scalars of the corresponding float dtype.
      eps: float
      max: float
      min: float
      # Note: smallest_normal is part of the array API spec, but cannot be used
      # until https://github.com/numpy/numpy/pull/18536 is merged.
  
      # smallest_normal: float
  
  @dataclass
  class iinfo_object:
      bits: int
      max: int
      min: int
  
  def finfo(type: Union[Dtype, Array], /) -> finfo_object:
      """
      Array API compatible wrapper for :py:func:`np.finfo <numpy.finfo>`.
  
      See its docstring for more information.
      """
      fi = np.finfo(type)
      # Note: The types of the float data here are float, whereas in NumPy they
      # are scalars of the corresponding float dtype.
      return finfo_object(
          fi.bits,
          float(fi.eps),
          float(fi.max),
          float(fi.min),
          # TODO: Uncomment this when #18536 is merged.
          # float(fi.smallest_normal),
      )
  
  def iinfo(type: Union[Dtype, Array], /) -> iinfo_object:
      """
      Array API compatible wrapper for :py:func:`np.iinfo <numpy.iinfo>`.
  
      See its docstring for more information.
      """
      ii = np.iinfo(type)
      return iinfo_object(ii.bits, ii.max, ii.min)
  
  def result_type(*arrays_and_dtypes: Sequence[Union[Array, Dtype]]) -> Dtype:
      """
      Array API compatible wrapper for :py:func:`np.result_type <numpy.result_type>`.
  
      See its docstring for more information.
      """
      A = []
      for a in arrays_and_dtypes:
          if isinstance(a, Array):
              a = a._array
          elif isinstance(a, np.ndarray) or a not in _all_dtypes:
              raise TypeError("result_type() inputs must be array_api arrays or dtypes")
          A.append(a)
  
      return np.result_type(*A)
  
files: numpy/_array_api/_data_type_functions.py
files: import numpy as np
  
  # Note: we use dtype objects instead of dtype classes. The spec does not
  # require any behavior on dtypes other than equality.
  int8 = np.dtype('int8')
  int16 = np.dtype('int16')
  int32 = np.dtype('int32')
  int64 = np.dtype('int64')
  uint8 = np.dtype('uint8')
  uint16 = np.dtype('uint16')
  uint32 = np.dtype('uint32')
  uint64 = np.dtype('uint64')
  float32 = np.dtype('float32')
  float64 = np.dtype('float64')
  # Note: This name is changed
  bool = np.dtype('bool')
  
  _all_dtypes = (int8, int16, int32, int64, uint8, uint16, uint32, uint64,
                 float32, float64, bool)
  _boolean_dtypes = (bool,)
  _floating_dtypes = (float32, float64)
  _integer_dtypes = (int8, int16, int32, int64, uint8, uint16, uint32, uint64)
  _integer_or_boolean_dtypes = (bool, int8, int16, int32, int64, uint8, uint16, uint32, uint64)
  _numeric_dtypes = (float32, float64, int8, int16, int32, int64, uint8, uint16, uint32, uint64)
  
  _promotion_table = {
      (int8, int8): int8,
      (int8, int16): int16,
      (int8, int32): int32,
      (int8, int64): int64,
      (int16, int8): int16,
      (int16, int16): int16,
      (int16, int32): int32,
      (int16, int64): int64,
      (int32, int8): int32,
      (int32, int16): int32,
      (int32, int32): int32,
      (int32, int64): int64,
      (int64, int8): int64,
      (int64, int16): int64,
      (int64, int32): int64,
      (int64, int64): int64,
      (uint8, uint8): uint8,
      (uint8, uint16): uint16,
      (uint8, uint32): uint32,
      (uint8, uint64): uint64,
      (uint16, uint8): uint16,
      (uint16, uint16): uint16,
      (uint16, uint32): uint32,
      (uint16, uint64): uint64,
      (uint32, uint8): uint32,
      (uint32, uint16): uint32,
      (uint32, uint32): uint32,
      (uint32, uint64): uint64,
      (uint64, uint8): uint64,
      (uint64, uint16): uint64,
      (uint64, uint32): uint64,
      (uint64, uint64): uint64,
      (int8, uint8): int16,
      (int8, uint16): int32,
      (int8, uint32): int64,
      (int16, uint8): int16,
      (int16, uint16): int32,
      (int16, uint32): int64,
      (int32, uint8): int32,
      (int32, uint16): int32,
      (int32, uint32): int64,
      (int64, uint8): int64,
      (int64, uint16): int64,
      (int64, uint32): int64,
      (uint8, int8): int16,
      (uint16, int8): int32,
      (uint32, int8): int64,
      (uint8, int16): int16,
      (uint16, int16): int32,
      (uint32, int16): int64,
      (uint8, int32): int32,
      (uint16, int32): int32,
      (uint32, int32): int64,
      (uint8, int64): int64,
      (uint16, int64): int64,
      (uint32, int64): int64,
      (float32, float32): float32,
      (float32, float64): float64,
      (float64, float32): float64,
      (float64, float64): float64,
      (bool, bool): bool,
  }
  
  def _result_type(type1, type2):
      if (type1, type2) in _promotion_table:
          return _promotion_table[type1, type2]
      raise TypeError(f"{type1} and {type2} cannot be type promoted together")
  
files: numpy/_array_api/_dtypes.py
files: import numpy as np
  
  # Note: we use dtype objects instead of dtype classes. The spec does not
  # require any behavior on dtypes other than equality.
  int8 = np.dtype('int8')
  int16 = np.dtype('int16')
  int32 = np.dtype('int32')
  int64 = np.dtype('int64')
  uint8 = np.dtype('uint8')
  uint16 = np.dtype('uint16')
  uint32 = np.dtype('uint32')
  uint64 = np.dtype('uint64')
  float32 = np.dtype('float32')
  float64 = np.dtype('float64')
  # Note: This name is changed
  bool = np.dtype('bool')
  
  _all_dtypes = (int8, int16, int32, int64, uint8, uint16, uint32, uint64,
                 float32, float64, bool)
  _boolean_dtypes = (bool,)
  _floating_dtypes = (float32, float64)
  _integer_dtypes = (int8, int16, int32, int64, uint8, uint16, uint32, uint64)
  _integer_or_boolean_dtypes = (bool, int8, int16, int32, int64, uint8, uint16, uint32, uint64)
  _numeric_dtypes = (float32, float64, int8, int16, int32, int64, uint8, uint16, uint32, uint64)
  
files: numpy/_array_api/_dtypes.py