docstr: Construct IntegerArray/FloatingArray from pyarrow Array/ChunkedArray.
docstr_tok: ["Construct","IntegerArray\/FloatingArray","from","pyarrow","Array\/ChunkedArray","."]
code: def __from_arrow__(
      self, array: pyarrow.Array | pyarrow.ChunkedArray
  ) -> BaseMaskedArray:
      """
      Construct IntegerArray/FloatingArray from pyarrow Array/ChunkedArray.
      """
      import pyarrow
  
      from pandas.core.arrays.arrow._arrow_utils import (
          pyarrow_array_to_numpy_and_mask,
      )
  
      array_class = self.construct_array_type()
  
      pyarrow_type = pyarrow.from_numpy_dtype(self.type)
      if not array.type.equals(pyarrow_type):
          # test_from_arrow_type_error raise for string, but allow
          #  through itemsize conversion GH#31896
          rt_dtype = pandas_dtype(array.type.to_pandas_dtype())
          if rt_dtype.kind not in ["i", "u", "f"]:
              # Could allow "c" or potentially disallow float<->int conversion,
              #  but at the moment we specifically test that uint<->int works
              raise TypeError(
                  f"Expected array of {self} type, got {array.type} instead"
              )
  
          array = array.cast(pyarrow_type)
  
      if isinstance(array, pyarrow.Array):
          chunks = [array]
      else:
          # pyarrow.ChunkedArray
          chunks = array.chunks
  
      results = []
      for arr in chunks:
          data, mask = pyarrow_array_to_numpy_and_mask(
              arr, dtype=self.numpy_dtype
          )
          num_arr = array_class(data.copy(), ~mask, copy=False)
          results.append(num_arr)
  
      if not results:
          return array_class(
              np.array([], dtype=self.numpy_dtype),
              np.array([], dtype=np.bool_),
          )
      elif len(results) == 1:
          # avoid additional copy in _concat_same_type
          return results[0]
      else:
          return array_class._concat_same_type(results)
  
imports: from __future__ import annotations
  import numbers
  from typing import TYPE_CHECKING, Any, Callable, Mapping, TypeVar
  import numpy
  from pandas._libs import lib, missing
  from pandas._typing import Dtype, DtypeObj, npt
  from pandas.errors import AbstractMethodError
  from pandas.util._decorators import cache_readonly
  from pandas.core.dtypes.common import is_bool_dtype, is_float_dtype, is_integer_dtype, is_object_dtype, is_string_dtype, pandas_dtype
  from pandas.core.arrays.masked import BaseMaskedArray, BaseMaskedDtype
label_desc: Use image node_id 5 for calling the NumericDtype obj's underlying member method code with example usage: obj.__from_arrow__(array) and returns: array_class, results, array_class