Skip to content

Commit d2c00c7

Browse files
committed
DOC: Make a note of can_cast not supporting int, float, complex
1 parent b296087 commit d2c00c7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

doc/source/release/2.0.0-notes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,16 @@ to achieve the previous behavior.
14961496

14971497
(`gh-25712 <https://github.com/numpy/numpy/pull/25712>`__)
14981498

1499+
``np.can_cast`` cannot be called on Python int, float, or complex
1500+
-----------------------------------------------------------------
1501+
``np.can_cast`` cannot be called with Python int, float, or complex instances
1502+
anymore. This is because NEP 50 means that the result of ``can_cast`` must
1503+
not depend on the value passed in.
1504+
Unfortunately, for Python scalars whether a cast should be considered
1505+
``"same_kind"`` or ``"safe"`` may depend on the context and value so that
1506+
this is currently not implemented.
1507+
In some cases, this means you may have to add a specific path for:
1508+
``if type(obj) in (int, float, complex): ...``.
14991509

15001510

15011511
**Content from release note snippets in doc/release/upcoming_changes:**

0 commit comments

Comments
 (0)