diff --git a/bigframes/dataframe.py b/bigframes/dataframe.py index c02b182ee3..d3d89c6a19 100644 --- a/bigframes/dataframe.py +++ b/bigframes/dataframe.py @@ -3705,7 +3705,9 @@ def to_numpy( ) -> numpy.ndarray: return self.to_pandas().to_numpy(dtype, copy, na_value, **kwargs) - def __array__(self, dtype=None) -> numpy.ndarray: + def __array__(self, dtype=None, copy: Optional[bool] = None) -> numpy.ndarray: + if copy is False: + raise ValueError("Cannot convert to array without copy.") return self.to_numpy(dtype=dtype) __array__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__array__) diff --git a/bigframes/series.py b/bigframes/series.py index fe2d1aae0e..a903f9823f 100644 --- a/bigframes/series.py +++ b/bigframes/series.py @@ -1812,7 +1812,9 @@ def to_numpy( ) -> numpy.ndarray: return self.to_pandas().to_numpy(dtype, copy, na_value, **kwargs) - def __array__(self, dtype=None) -> numpy.ndarray: + def __array__(self, dtype=None, copy: Optional[bool] = None) -> numpy.ndarray: + if copy is False: + raise ValueError("Cannot convert to array without copy.") return self.to_numpy(dtype=dtype) __array__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__array__) diff --git a/third_party/bigframes_vendored/pandas/core/frame.py b/third_party/bigframes_vendored/pandas/core/frame.py index f5aa23d00b..e296dcb9f6 100644 --- a/third_party/bigframes_vendored/pandas/core/frame.py +++ b/third_party/bigframes_vendored/pandas/core/frame.py @@ -7179,7 +7179,7 @@ def __len__(self): """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) - def __array__(self): + def __array__(self, dtype=None, copy: Optional[bool] = None): """ Returns the rows as NumPy array. @@ -7210,6 +7210,8 @@ def __array__(self): dtype (str or numpy.dtype, optional): The dtype to use for the resulting NumPy array. By default, the dtype is inferred from the data. + copy (bool or None, optional): + Whether to copy the data, False is not supported. Returns: numpy.ndarray: diff --git a/third_party/bigframes_vendored/pandas/core/series.py b/third_party/bigframes_vendored/pandas/core/series.py index 57f7dfbb79..5e6f546d09 100644 --- a/third_party/bigframes_vendored/pandas/core/series.py +++ b/third_party/bigframes_vendored/pandas/core/series.py @@ -5941,7 +5941,7 @@ def size(self) -> int: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) - def __array__(self, dtype=None) -> numpy.ndarray: + def __array__(self, dtype=None, copy: Optional[bool] = None) -> numpy.ndarray: """ Returns the values as NumPy array. @@ -5965,6 +5965,8 @@ def __array__(self, dtype=None) -> numpy.ndarray: dtype (str or numpy.dtype, optional): The dtype to use for the resulting NumPy array. By default, the dtype is inferred from the data. + copy (bool or None, optional): + Whether to copy the data, False is not supported. Returns: numpy.ndarray: