-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
DOC: Enumerate the differences between numpy and numpy.array_api #21260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
7ed0189
f306e94
f375d71
b5ac835
4457e37
d29368e
a3624db
9bd3b6e
be1f91c
3b38438
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,7 +233,7 @@ independently of values or shapes. | |
* - ``__pow__`` and ``__rpow__`` do not do value-based casting for 0-D | ||
arrays. | ||
- **Breaking** | ||
- For example, ``np.array(0., dtype=float32)*np.array(0., | ||
- For example, ``np.array(0., dtype=float32)**np.array(0., | ||
dtype=float64)`` is ``float32``. Note that this is value-based casting | ||
on 0-D arrays, not scalars. | ||
* - No cross-kind casting. | ||
|
@@ -534,11 +534,13 @@ Array Object Differences | |
- Type | ||
- Notes | ||
* - No array scalars | ||
- ??? | ||
- The spec does not have array scalars, only 0-D arrays. It is not clear | ||
if NumPy's scalars deviate from the spec 0-D array behavior in any ways | ||
other than the ones outlined in | ||
:ref:`array_api-type-promotion-differences`. | ||
- **Strictness** | ||
- The spec does not have array scalars, only 0-D arrays. However, other | ||
than the promotion differences outlined in | ||
:ref:`array_api-type-promotion-differences`, scalars duck type as 0-D | ||
arrays for the purposes of the spec. The are immutable, but the spec | ||
`does not require mutability | ||
<https://data-apis.org/array-api/latest/design_topics/copies_views_and_mutation.html>`__. | ||
* - ``bool()``, ``int()``, and ``float()`` only work on 0-D arrays. | ||
- **Strictness** | ||
- See https://github.com/numpy/numpy/issues/10404. | ||
|
@@ -627,7 +629,8 @@ Linear Algebra Differences | |
- | ||
* - ``diagonal`` operates on the last two axes. | ||
- **Breaking** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But you are moving it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hadn't considered that. I'll leave it as "breaking" but add a note about this. This is definitely one of the worst "breaking" cases here for NumPy. NumPy's |
||
- | ||
- Strictly speaking this can be **compatible** because ``diagonal`` is | ||
moved to the ``linalg`` namespace. | ||
* - ``eigh``, ``qr``, ``slogdet`` and ``svd`` return a named tuple. | ||
- **Compatible** | ||
- The corresponding ``numpy`` functions return a ``tuple``, with the | ||
|
@@ -637,7 +640,7 @@ Linear Algebra Differences | |
- The ``norm`` function has been omitted from the array API and split | ||
into ``matrix_norm`` for matrix norms and ``vector_norm`` for vector | ||
norms. Note that ``vector_norm`` supports any number of axes, whereas | ||
``np.norm`` only supports a single axis for vector norms. | ||
``np.linalg.norm`` only supports a single axis for vector norms. | ||
* - ``matrix_rank`` has an ``rtol`` keyword argument instead of ``tol``. | ||
- **Compatible** | ||
- In the array API, ``rtol`` filters singular values smaller than | ||
|
@@ -698,7 +701,7 @@ Manipulation Functions Differences | |
- No cross-kind casting. No value-based casting on scalars. | ||
* - ``stack`` has different default casting rules from ``np.stack`` | ||
- **Strictness** | ||
- No cross-kind casting. No value-based casting on scalars. | ||
- No cross-kind casting. | ||
* - New function ``permute_dims``. | ||
- **Compatible** | ||
- Unlike ``np.transpose``, the ``axis`` keyword argument to | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example is meant to use
**
, and maybe can just be considered a bug, since it does not use the typical promotion rules. But then, if we change promotion rules, this should just align anyway, so it hardly matters.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't tell what's a bug or not when it comes to value-based casting. It definitely is odd that
__pow__
is the only operator that does this.