4 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -3705,7 +3705,9 @@ def to_numpy(
3705
3705
) -> numpy .ndarray :
3706
3706
return self .to_pandas ().to_numpy (dtype , copy , na_value , ** kwargs )
3707
3707
3708
- def __array__ (self , dtype = None ) -> numpy .ndarray :
3708
+ def __array__ (self , dtype = None , copy : Optional [bool ] = None ) -> numpy .ndarray :
3709
+ if copy is False :
3710
+ raise ValueError ("Cannot convert to array without copy." )
3709
3711
return self .to_numpy (dtype = dtype )
3710
3712
3711
3713
__array__ .__doc__ = inspect .getdoc (vendored_pandas_frame .DataFrame .__array__ )
Original file line number Diff line number Diff line change @@ -1812,7 +1812,9 @@ def to_numpy(
1812
1812
) -> numpy .ndarray :
1813
1813
return self .to_pandas ().to_numpy (dtype , copy , na_value , ** kwargs )
1814
1814
1815
- def __array__ (self , dtype = None ) -> numpy .ndarray :
1815
+ def __array__ (self , dtype = None , copy : Optional [bool ] = None ) -> numpy .ndarray :
1816
+ if copy is False :
1817
+ raise ValueError ("Cannot convert to array without copy." )
1816
1818
return self .to_numpy (dtype = dtype )
1817
1819
1818
1820
__array__ .__doc__ = inspect .getdoc (vendored_pandas_series .Series .__array__ )
Original file line number Diff line number Diff line change @@ -7179,7 +7179,7 @@ def __len__(self):
7179
7179
"""
7180
7180
raise NotImplementedError (constants .ABSTRACT_METHOD_ERROR_MESSAGE )
7181
7181
7182
- def __array__ (self ):
7182
+ def __array__ (self , dtype = None , copy : Optional [ bool ] = None ):
7183
7183
"""
7184
7184
Returns the rows as NumPy array.
7185
7185
@@ -7210,6 +7210,8 @@ def __array__(self):
7210
7210
dtype (str or numpy.dtype, optional):
7211
7211
The dtype to use for the resulting NumPy array. By default,
7212
7212
the dtype is inferred from the data.
7213
+ copy (bool or None, optional):
7214
+ Whether to copy the data, False is not supported.
7213
7215
7214
7216
Returns:
7215
7217
numpy.ndarray:
Original file line number Diff line number Diff line change @@ -5941,7 +5941,7 @@ def size(self) -> int:
5941
5941
"""
5942
5942
raise NotImplementedError (constants .ABSTRACT_METHOD_ERROR_MESSAGE )
5943
5943
5944
- def __array__ (self , dtype = None ) -> numpy .ndarray :
5944
+ def __array__ (self , dtype = None , copy : Optional [ bool ] = None ) -> numpy .ndarray :
5945
5945
"""
5946
5946
Returns the values as NumPy array.
5947
5947
@@ -5965,6 +5965,8 @@ def __array__(self, dtype=None) -> numpy.ndarray:
5965
5965
dtype (str or numpy.dtype, optional):
5966
5966
The dtype to use for the resulting NumPy array. By default,
5967
5967
the dtype is inferred from the data.
5968
+ copy (bool or None, optional):
5969
+ Whether to copy the data, False is not supported.
5968
5970
5969
5971
Returns:
5970
5972
numpy.ndarray:
0 commit comments