files.new_contents: """
  Wrapper class around the ndarray object for the array API standard.
  
  The array API standard defines some behaviors differently than ndarray, in
  particular, type promotion rules are different (the standard has no
  value-based casting). The standard also specifies a more limited subset of
  array methods and functionalities than are implemented on ndarray. Since the
  goal of the array_api namespace is to be a minimal implementation of the array
  API standard, we need to define a separate wrapper class for the array_api
  namespace.
  
  The standard compliant class is only a wrapper class. It is *not* a subclass
  of ndarray.
  """
  
  from __future__ import annotations
  
  import operator
  from enum import IntEnum
  from ._creation_functions import asarray
  from ._dtypes import _boolean_dtypes, _integer_dtypes, _floating_dtypes
  
  from typing import TYPE_CHECKING, Any, Optional, Tuple, Union
  if TYPE_CHECKING:
      from ._typing import PyCapsule, Device, Dtype
  
  import numpy as np
  
  class Array:
      """
      n-d array object for the array API namespace.
  
      See the docstring of :py:obj:`np.ndarray <numpy.ndarray>` for more
      information.
  
      This is a wrapper around numpy.ndarray that restricts the usage to only
      those things that are required by the array API namespace. Note,
      attributes on this object that start with a single underscore are not part
      of the API specification and should only be used internally. This object
      should not be constructed directly. Rather, use one of the creation
      functions, such as asarray().
  
      """
      # Use a custom constructor instead of __init__, as manually initializing
      # this class is not supported API.
      @classmethod
      def _new(cls, x, /):
          """
          This is a private method for initializing the array API Array
          object.
  
          Functions outside of the array_api submodule should not use this
          method. Use one of the creation functions instead, such as
          ``asarray``.
  
          """
          obj = super().__new__(cls)
          # Note: The spec does not have array scalars, only shape () arrays.
          if isinstance(x, np.generic):
              # Convert the array scalar to a shape () array
              xa = np.empty((), x.dtype)
              xa[()] = x
              x = xa
          obj._array = x
          return obj
  
      # Prevent Array() from working
      def __new__(cls, *args, **kwargs):
          raise TypeError("The array_api Array object should not be instantiated directly. Use an array creation function, such as asarray(), instead.")
  
      # These functions are not required by the spec, but are implemented for
      # the sake of usability.
  
      def __str__(self: Array, /) -> str:
          """
          Performs the operation __str__.
          """
          return self._array.__str__().replace('array', 'Array')
  
      def __repr__(self: Array, /) -> str:
          """
          Performs the operation __repr__.
          """
          return self._array.__repr__().replace('array', 'Array')
  
      # Helper function to match the type promotion rules in the spec
      def _promote_scalar(self, scalar):
          """
          Returns a promoted version of a Python scalar appropriate for use with
          operations on self.
  
          This may raise an OverflowError in cases where the scalar is an
          integer that is too large to fit in a NumPy integer dtype, or
          TypeError when the scalar type is incompatible with the dtype of self.
          """
          if isinstance(scalar, bool):
              if self.dtype not in _boolean_dtypes:
                  raise TypeError("Python bool scalars can only be promoted with bool arrays")
          elif isinstance(scalar, int):
              if self.dtype in _boolean_dtypes:
                  raise TypeError("Python int scalars cannot be promoted with bool arrays")
          elif isinstance(scalar, float):
              if self.dtype not in _floating_dtypes:
                  raise TypeError("Python float scalars can only be promoted with floating-point arrays.")
          else:
              raise TypeError("'scalar' must be a Python scalar")
  
          # Note: the spec only specifies integer-dtype/int promotion
          # behavior for integers within the bounds of the integer dtype.
          # Outside of those bounds we use the default NumPy behavior (either
          # cast or raise OverflowError).
          return Array._new(np.array(scalar, self.dtype))
  
      @staticmethod
      def _normalize_two_args(x1, x2):
          """
          Normalize inputs to two arg functions to fix type
  
  [... the rest is omitted ...]
files.new_path: numpy/_array_api/_array_object.py
files.old_contents: """
  Wrapper class around the ndarray object for the array API standard.
  
  The array API standard defines some behaviors differently than ndarray, in
  particular, type promotion rules are different (the standard has no
  value-based casting). The standard also specifies a more limited subset of
  array methods and functionalities than are implemented on ndarray. Since the
  goal of the array_api namespace is to be a minimal implementation of the array
  API standard, we need to define a separate wrapper class for the array_api
  namespace.
  
  The standard compliant class is only a wrapper class. It is *not* a subclass
  of ndarray.
  """
  
  from __future__ import annotations
  
  import operator
  from enum import IntEnum
  from ._creation_functions import asarray
  from ._dtypes import _boolean_dtypes, _integer_dtypes, _floating_dtypes
  
  from typing import TYPE_CHECKING, Any, Optional, Tuple, Union
  if TYPE_CHECKING:
      from ._typing import PyCapsule, Device, Dtype
  
  import numpy as np
  
  class Array:
      """
      n-d array object for the array API namespace.
  
      See the docstring of :py:obj:`np.ndarray <numpy.ndarray>` for more
      information.
  
      This is a wrapper around numpy.ndarray that restricts the usage to only
      those things that are required by the array API namespace. Note,
      attributes on this object that start with a single underscore are not part
      of the API specification and should only be used internally. This object
      should not be constructed directly. Rather, use one of the creation
      functions, such as asarray().
  
      """
      # Use a custom constructor instead of __init__, as manually initializing
      # this class is not supported API.
      @classmethod
      def _new(cls, x, /):
          """
          This is a private method for initializing the array API Array
          object.
  
          Functions outside of the array_api submodule should not use this
          method. Use one of the creation functions instead, such as
          ``asarray``.
  
          """
          obj = super().__new__(cls)
          # Note: The spec does not have array scalars, only shape () arrays.
          if isinstance(x, np.generic):
              # Convert the array scalar to a shape () array
              xa = np.empty((), x.dtype)
              xa[()] = x
              x = xa
          obj._array = x
          return obj
  
      # Prevent Array() from working
      def __new__(cls, *args, **kwargs):
          raise TypeError("The array_api Array object should not be instantiated directly. Use an array creation function, such as asarray(), instead.")
  
      # These functions are not required by the spec, but are implemented for
      # the sake of usability.
  
      def __str__(self: Array, /) -> str:
          """
          Performs the operation __str__.
          """
          return self._array.__str__().replace('array', 'Array')
  
      def __repr__(self: Array, /) -> str:
          """
          Performs the operation __repr__.
          """
          return self._array.__repr__().replace('array', 'Array')
  
      # Helper function to match the type promotion rules in the spec
      def _promote_scalar(self, scalar):
          """
          Returns a promoted version of a Python scalar appropriate for use with
          operations on self.
  
          This may raise an OverflowError in cases where the scalar is an
          integer that is too large to fit in a NumPy integer dtype, or
          TypeError when the scalar type is incompatible with the dtype of self.
          """
          if isinstance(scalar, bool):
              if self.dtype not in _boolean_dtypes:
                  raise TypeError("Python bool scalars can only be promoted with bool arrays")
          elif isinstance(scalar, int):
              if self.dtype in _boolean_dtypes:
                  raise TypeError("Python int scalars cannot be promoted with bool arrays")
          elif isinstance(scalar, float):
              if self.dtype not in _floating_dtypes:
                  raise TypeError("Python float scalars can only be promoted with floating-point arrays.")
          else:
              raise TypeError("'scalar' must be a Python scalar")
  
          # Note: the spec only specifies integer-dtype/int promotion
          # behavior for integers within the bounds of the integer dtype.
          # Outside of those bounds we use the default NumPy behavior (either
          # cast or raise OverflowError).
          return Array._new(np.array(scalar, self.dtype))
  
      @staticmethod
      def _normalize_two_args(x1, x2):
          """
          Normalize inputs to two arg functions to fix type
  
  [... the rest is omitted ...]
files.old_path: numpy/_array_api/_array_object.py
files.new_contents: from __future__ import annotations
  
  from ._dtypes import (_boolean_dtypes, _floating_dtypes,
                        _integer_dtypes, _integer_or_boolean_dtypes,
                        _numeric_dtypes)
  from ._array_object import Array
  
  import numpy as np
  
  def abs(x: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.abs <numpy.abs>`.
  
      See its docstring for more information.
      """
      if x.dtype not in _numeric_dtypes:
          raise TypeError('Only numeric dtypes are allowed in abs')
      return Array._new(np.abs(x._array))
  
  # Note: the function name is different here
  @np.errstate(all='ignore')
  def acos(x: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.arccos <numpy.arccos>`.
  
      See its docstring for more information.
      """
      if x.dtype not in _floating_dtypes:
          raise TypeError('Only floating-point dtypes are allowed in acos')
      return Array._new(np.arccos(x._array))
  
  # Note: the function name is different here
  @np.errstate(all='ignore')
  def acosh(x: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.arccosh <numpy.arccosh>`.
  
      See its docstring for more information.
      """
      if x.dtype not in _floating_dtypes:
          raise TypeError('Only floating-point dtypes are allowed in acosh')
      return Array._new(np.arccosh(x._array))
  
  @np.errstate(all='ignore')
  def add(x1: Array, x2: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.add <numpy.add>`.
  
      See its docstring for more information.
      """
      if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes:
          raise TypeError('Only numeric dtypes are allowed in add')
      x1, x2 = Array._normalize_two_args(x1, x2)
      return Array._new(np.add(x1._array, x2._array))
  
  # Note: the function name is different here
  @np.errstate(all='ignore')
  def asin(x: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.arcsin <numpy.arcsin>`.
  
      See its docstring for more information.
      """
      if x.dtype not in _floating_dtypes:
          raise TypeError('Only floating-point dtypes are allowed in asin')
      return Array._new(np.arcsin(x._array))
  
  # Note: the function name is different here
  @np.errstate(all='ignore')
  def asinh(x: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.arcsinh <numpy.arcsinh>`.
  
      See its docstring for more information.
      """
      if x.dtype not in _floating_dtypes:
          raise TypeError('Only floating-point dtypes are allowed in asinh')
      return Array._new(np.arcsinh(x._array))
  
  # Note: the function name is different here
  def atan(x: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.arctan <numpy.arctan>`.
  
      See its docstring for more information.
      """
      if x.dtype not in _floating_dtypes:
          raise TypeError('Only floating-point dtypes are allowed in atan')
      return Array._new(np.arctan(x._array))
  
  # Note: the function name is different here
  def atan2(x1: Array, x2: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.arctan2 <numpy.arctan2>`.
  
      See its docstring for more information.
      """
      if x1.dtype not in _floating_dtypes or x2.dtype not in _floating_dtypes:
          raise TypeError('Only floating-point dtypes are allowed in atan2')
      x1, x2 = Array._normalize_two_args(x1, x2)
      return Array._new(np.arctan2(x1._array, x2._array))
  
  # Note: the function name is different here
  @np.errstate(all='ignore')
  def atanh(x: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.arctanh <numpy.arctanh>`.
  
  
  
  [... the rest is omitted ...]
files.new_path: numpy/_array_api/_elementwise_functions.py
files.old_contents: from __future__ import annotations
  
  from ._dtypes import (_boolean_dtypes, _floating_dtypes,
                        _integer_dtypes, _integer_or_boolean_dtypes,
                        _numeric_dtypes)
  from ._array_object import Array
  
  import numpy as np
  
  def abs(x: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.abs <numpy.abs>`.
  
      See its docstring for more information.
      """
      if x.dtype not in _numeric_dtypes:
          raise TypeError('Only numeric dtypes are allowed in abs')
      return Array._new(np.abs(x._array))
  
  # Note: the function name is different here
  @np.errstate(all='ignore')
  def acos(x: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.arccos <numpy.arccos>`.
  
      See its docstring for more information.
      """
      if x.dtype not in _floating_dtypes:
          raise TypeError('Only floating-point dtypes are allowed in acos')
      return Array._new(np.arccos(x._array))
  
  # Note: the function name is different here
  @np.errstate(all='ignore')
  def acosh(x: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.arccosh <numpy.arccosh>`.
  
      See its docstring for more information.
      """
      if x.dtype not in _floating_dtypes:
          raise TypeError('Only floating-point dtypes are allowed in acosh')
      return Array._new(np.arccosh(x._array))
  
  @np.errstate(all='ignore')
  def add(x1: Array, x2: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.add <numpy.add>`.
  
      See its docstring for more information.
      """
      if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes:
          raise TypeError('Only numeric dtypes are allowed in add')
      x1, x2 = Array._normalize_two_args(x1, x2)
      return Array._new(np.add(x1._array, x2._array))
  
  # Note: the function name is different here
  @np.errstate(all='ignore')
  def asin(x: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.arcsin <numpy.arcsin>`.
  
      See its docstring for more information.
      """
      if x.dtype not in _floating_dtypes:
          raise TypeError('Only floating-point dtypes are allowed in asin')
      return Array._new(np.arcsin(x._array))
  
  # Note: the function name is different here
  @np.errstate(all='ignore')
  def asinh(x: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.arcsinh <numpy.arcsinh>`.
  
      See its docstring for more information.
      """
      if x.dtype not in _floating_dtypes:
          raise TypeError('Only floating-point dtypes are allowed in asinh')
      return Array._new(np.arcsinh(x._array))
  
  # Note: the function name is different here
  def atan(x: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.arctan <numpy.arctan>`.
  
      See its docstring for more information.
      """
      if x.dtype not in _floating_dtypes:
          raise TypeError('Only floating-point dtypes are allowed in atan')
      return Array._new(np.arctan(x._array))
  
  # Note: the function name is different here
  def atan2(x1: Array, x2: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.arctan2 <numpy.arctan2>`.
  
      See its docstring for more information.
      """
      if x1.dtype not in _floating_dtypes or x2.dtype not in _floating_dtypes:
          raise TypeError('Only floating-point dtypes are allowed in atan2')
      x1, x2 = Array._normalize_two_args(x1, x2)
      return Array._new(np.arctan2(x1._array, x2._array))
  
  # Note: the function name is different here
  @np.errstate(all='ignore')
  def atanh(x: Array, /) -> Array:
      """
      Array API compatible wrapper for :py:func:`np.arctanh <numpy.arctanh>`.
  
  
  
  [... the rest is omitted ...]
files.old_path: numpy/_array_api/_elementwise_functions.py