8000 docs: add design topic on `copy` keyword argument behavior by kgryte · Pull Request #906 · data-apis/array-api · GitHub
[go: up one dir, main page]

Skip to content

docs: add design topic on copy keyword argument behavior #906

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

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
chore: link to design topic
  • Loading branch information
kgryte committed Feb 26, 2025
commit f6dc711114c333b726775b0fdbf58b7843b49be9
3 changes: 3 additions & 0 deletions spec/draft/design_topics/copies_views_and_mutation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ standard, it remains possible to write code that will not work the same for all
array libraries. This is something that the users are advised to best keep in
mind and to reason carefully about the potential ambiguity of implemented code.


.. _copy-keyword-argument:

Copy keyword argument behavior
------------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/array_api_stubs/_draft/array_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def __dlpack__(
API standard.
copy: Optional[bool]
boolean indicating whether or not to copy the input. If ``True``, the
function must always copy (performed by the producer). If ``False``, the
function must always copy (performed by the producer; see also :ref:`copy-keyword-argument`). If ``False``, the
function must never copy, and raise a ``BufferError`` in case a copy is
deemed necessary (e.g. if a cross-device data movement is requested, and
it is not possible without a copy). If ``None``, the function must reuse
Expand Down
2 changes: 1 addition & 1 deletion src/array_api_stubs/_draft/creation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def asarray(
device: Optional[device]
device on which to place the created array. If ``device`` is ``None`` and ``obj`` is an array, the output array device must be inferred from ``obj``. Default: ``None``.
copy: Optional[bool]
boolean indicating whether or not to copy the input. If ``True``, the function must always copy. If ``False``, the function must never copy for input which supports the buffer protocol and must raise a ``ValueError`` in case a copy would be necessary. If ``None``, the function must reuse existing memory buffer if possible and copy otherwise. Default: ``None``.
boolean indicating whether or not to copy the input. If ``True``, the function must always copy (see :ref:`copy-keyword-argument`). If ``False``, the function must never copy for input which supports the buffer protocol and must raise a ``ValueError`` in case a copy would be necessary. If ``None``, the function must reuse existing memory buffer if possible and copy otherwise. Default: ``None``.

Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion src/array_api_stubs/_draft/data_type_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def astype(
dtype: dtype
desired data type.
copy: bool
specifies whether to copy an array when the specified ``dtype`` matches the data type of the input array ``x``. If ``True``, a newly allocated array must always be returned. If ``False`` and the specified ``dtype`` matches the data type of the input array, the input array must be returned; otherwise, a newly allocated array must be returned. Default: ``True``.
specifies whether to copy an array when the specified ``dtype`` matches the data type of the input array ``x``. If ``True``, a newly allocated array must always be returned (see :ref:`copy-keyword-argument`). If ``False`` and the specified ``dtype`` matches the data type of the input array, the input array must be returned; otherwise, a newly allocated array must be returned. Default: ``True``.
device: Optional[device]
device on which to place the returned array. If ``device`` is ``None``, the output array device must be inferred from ``x``. Default: ``None``.

Expand Down
2 changes: 1 addition & 1 deletion src/array_api_stubs/_draft/manipulation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def reshape(
shape: Tuple[int, ...]
a new shape compatible with the original shape. One shape dimension is allowed to be ``-1``. When a shape dimension is ``-1``, the corresponding output array shape dimension must be inferred from the length of the array and the remaining dimensions.
copy: Optional[bool]
whether or not to copy the input array. If ``True``, the function must always copy. If ``False``, the function must never copy. If ``None``, the function must avoid copying, if possible, and may copy otherwise. Default: ``None``.
whether or not to copy the input array. If ``True``, the function must always copy (see :ref:`copy-keyword-argument`). If ``False``, the function must never copy. If ``None``, the function must avoid copying, if possible, and may copy otherwise. Default: ``None``.

Returns
-------
Expand Down
0