Skip to content

Commit f419a91

Browse files
committed
update warning msg on all __array__
1 parent 1c5d103 commit f419a91

File tree

8 files changed

+47
-40
lines changed

8 files changed

+47
-40
lines changed

pandas/core/arrays/categorical.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,11 +1673,12 @@ def __array__(
16731673
"""
16741674
if copy is False:
16751675
warnings.warn(
1676-
"Starting on NumPy 2.0, the behavior of the 'copy' keyword has changed "
1677-
"and passing 'copy=False' raises an error when a zero-copy NumPy array "
1678-
"is not possible, Pandas will follow this behavior starting with "
1679-
"version 3.0. This conversion to NumPy requires a copy, but "
1680-
"'copy=False' was passed. Consider using 'np.asarray(..)' instead.",
1676+
"Starting with NumPy 2.0, the behavior of the 'copy' keyword has "
1677+
"changed and passing 'copy=False' raises an error when returning "
1678+
"a zero-copy NumPy array is not possible. pandas will follow "
1679+
"this behavior starting with pandas 3.0.\nThis conversion to "
1680+
"NumPy requires a copy, but 'copy=False' was passed. Consider "
1681+
"using 'np.asarray(..)' instead.",
16811682
FutureWarning,
16821683
stacklevel=find_stack_level(),
16831684
)

pandas/core/arrays/datetimelike.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,11 @@ def __array__(
360360
if is_object_dtype(dtype):
361361
if copy is False:
362362
warnings.warn(
363-
"Starting on NumPy 2.0, the behavior of the 'copy' keyword has "
364-
"changed and passing 'copy=False' raises an error when a zero-copy "
365-
"NumPy array is not possible, Pandas will follow this behavior "
366-
"starting with version 3.0. This conversion to NumPy requires a "
367-
"copy, but 'copy=False' was passed. Consider using "
363+
"Starting with NumPy 2.0, the behavior of the 'copy' keyword has "
364+
"changed and passing 'copy=False' raises an error when returning "
365+
"a zero-copy NumPy array is not possible. pandas will follow this "
366+
"behavior starting with pandas 3.0.\nThis conversion to NumPy "
367+
"requires a copy, but 'copy=False' was passed. Consider using "
368368
"'np.asarray(..)' instead.",
369369
FutureWarning,
370370
stacklevel=find_stack_level(),

pandas/core/arrays/interval.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,11 +1577,12 @@ def __array__(
15771577
"""
15781578
if copy is False:
15791579
warnings.warn(
1580-
"Starting on NumPy 2.0, the behavior of the 'copy' keyword has changed "
1581-
"and passing 'copy=False' raises an error when a zero-copy NumPy array "
1582-
"is not possible, Pandas will follow this behavior starting with "
1583-
"version 3.0. This conversion to NumPy requires a copy, but "
1584-
"'copy=False' was passed. Consider using 'np.asarray(..)' instead.",
1580+
"Starting with NumPy 2.0, the behavior of the 'copy' keyword has "
1581+
"changed and passing 'copy=False' raises an error when returning "
1582+
"a zero-copy NumPy array is not possible. pandas will follow "
1583+
"this behavior starting with pandas 3.0.\nThis conversion to "
1584+
"NumPy requires a copy, but 'copy=False' was passed. Consider "
1585+
"using 'np.asarray(..)' instead.",
15851586
FutureWarning,
15861587
stacklevel=find_stack_level(),
15871588
)

pandas/core/arrays/masked.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -607,11 +607,12 @@ def __array__(
607607
return np.array(self._data, dtype=dtype, copy=copy)
608608

609609
warnings.warn(
610-
"Starting on NumPy 2.0, the behavior of the 'copy' keyword has changed "
611-
"and passing 'copy=False' raises an error when a zero-copy NumPy array "
612-
"is not possible, Pandas will follow this behavior starting with "
613-
"version 3.0. This conversion to NumPy requires a copy, but "
614-
"'copy=False' was passed. Consider using 'np.asarray(..)' instead.",
610+
"Starting with NumPy 2.0, the behavior of the 'copy' keyword has "
611+
"changed and passing 'copy=False' raises an error when returning "
612+
"a zero-copy NumPy array is not possible. pandas will follow "
613+
"this behavior starting with pandas 3.0.\nThis conversion to "
614+
"NumPy requires a copy, but 'copy=False' was passed. Consider "
615+
"using 'np.asarray(..)' instead.",
615616
FutureWarning,
616617
stacklevel=find_stack_level(),
617618
)

pandas/core/arrays/period.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,12 @@ def __array__(
416416

417417
if copy is False:
418418
warnings.warn(
419-
"Starting on NumPy 2.0, the behavior of the 'copy' keyword has changed "
420-
"and passing 'copy=False' raises an error when a zero-copy NumPy array "
421-
"is not possible, Pandas will follow this behavior starting with "
422-
"version 3.0. This conversion to NumPy requires a copy, but "
423-
"'copy=False' was passed. Consider using 'np.asarray(..)' instead.",
419+
"Starting with NumPy 2.0, the behavior of the 'copy' keyword has "
420+
"changed and passing 'copy=False' raises an error when returning "
421+
"a zero-copy NumPy array is not possible. pandas will follow "
422+
"this behavior starting with pandas 3.0.\nThis conversion to "
423+
"NumPy requires a copy, but 'copy=False' was passed. Consider "
424+
"using 'np.asarray(..)' instead.",
424425
FutureWarning,
425426
stacklevel=find_stack_level(),
426427
)

pandas/core/arrays/sparse/array.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,12 @@ def __array__(
563563

564564
if copy is False:
565565
warnings.warn(
566-
"Starting on NumPy 2.0, the behavior of the 'copy' keyword has changed "
567-
"and passing 'copy=False' raises an error when a zero-copy NumPy array "
568-
"is not possible, Pandas will follow this behavior starting with "
569-
"version 3.0. This conversion to NumPy requires a copy, but "
570-
"'copy=False' was passed. Consider using 'np.asarray(..)' instead.",
566+
"Starting with NumPy 2.0, the behavior of the 'copy' keyword has "
567+
"changed and passing 'copy=False' raises an error when returning "
568+
"a zero-copy NumPy array is not possible. pandas will follow "
569+
"this behavior starting with pandas 3.0.\nThis conversion to "
570+
"NumPy requires a copy, but 'copy=False' was passed. Consider "
571+
"using 'np.asarray(..)' instead.",
571572
FutureWarning,
572573
stacklevel=find_stack_level(),
573574
)

pandas/core/generic.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,11 +2153,12 @@ def __array__(
21532153
# check this manually, otherwise ._values will already return a copy
21542154
# and np.array(values, copy=False) will not raise a warning
21552155
warnings.warn(
2156-
"Starting on NumPy 2.0, the behavior of the 'copy' keyword has changed "
2157-
"and passing 'copy=False' raises an error when a zero-copy NumPy array "
2158-
"is not possible, Pandas will follow this behavior starting with "
2159-
"version 3.0. This conversion to NumPy requires a copy, but "
2160-
"'copy=False' was passed. Consider using 'np.asarray(..)' instead.",
2156+
"Starting with NumPy 2.0, the behavior of the 'copy' keyword has "
2157+
"changed and passing 'copy=False' raises an error when returning "
2158+
"a zero-copy NumPy array is not possible. pandas will follow "
2159+
"this behavior starting with pandas 3.0.\nThis conversion to "
2160+
"NumPy requires a copy, but 'copy=False' was passed. Consider "
2161+
"using 'np.asarray(..)' instead.",
21612162
FutureWarning,
21622163
stacklevel=find_stack_level(),
21632164
)

pandas/core/indexes/multi.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,11 +1315,12 @@ def __array__(self, dtype=None, copy=None) -> np.ndarray:
13151315
if copy is False:
13161316
# self.values is always a newly construct array, so raise.
13171317
warnings.warn(
1318-
"Starting on NumPy 2.0, the behavior of the 'copy' keyword has changed "
1319-
"and passing 'copy=False' raises an error when a zero-copy NumPy array "
1320-
"is not possible, Pandas will follow this behavior starting with "
1321-
"version 3.0. This conversion to NumPy requires a copy, but "
1322-
"'copy=False' was passed. Consider using 'np.asarray(..)' instead.",
1318+
"Starting with NumPy 2.0, the behavior of the 'copy' keyword has "
1319+
"changed and passing 'copy=False' raises an error when returning "
1320+
"a zero-copy NumPy array is not possible. pandas will follow "
1321+
"this behavior starting with pandas 3.0.\nThis conversion to "
1322+
"NumPy requires a copy, but 'copy=False' was passed. Consider "
1323+
"using 'np.asarray(..)' instead.",
13231324
FutureWarning,
13241325
stacklevel=find_stack_level(),
13251326
)

0 commit comments

Comments
 (0)