`asarray` with `copy=False` produces new array?
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 50/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- python
- Domain
- documentation
Research direction
Start by comparing the specification wording for asarray and astype with the examples in the issue, then check how the existing standard text addresses object identity versus shared memory. Done means resolving whether copy=False requires returning the same array object and making the specification unambiguous.
Written by the indexing model from the issue text.
Description
This may be related to gh-788, but I think it is distinct.
The behavior of astype with copy=False is:
If
Falseand the specified dtype matches the data type of the input array, the input array must be returned...
So this passes:
import array_api_strict as xp
dtype = xp.int64
x = xp.asarray([1, 2, 3], dtype=dtype)
y = xp.astype(x, dtype, copy=False)
assert y is x
For asarray:
If
False, the function must never copy for input which supports the buffer protocol...
Here, it is not explicit whether "must never copy" refers to the array object itself or the underlying memory buffer. In any case, array_api_strict creates a new array object, so the equivalent assertion fails.
y = xp.asarray(x, dtype=dtype, copy=False)
assert y is x
# AssertionError:
Is "must never copy" intended to allow the returned object to be different from the input? Either way, should it be more explicit?
If it helps, NumPy, PyTorch, JAX, and Dask all pass both assertions.
- Dominant language
- Python
- Stars
- 281
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from data-apis/array-api
-
bug Maintenance Narrative Content
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Maintenance
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
All issues in data-apis/array-api
Similar issues
-
essnmx good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
[Feature] 奇物选择添加优先级 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
syfoud/Simulated_Scepter#174 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Giskard-AI/giskard-oss#2840 · 1 comment ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Openarea: repo bug perceived difficulty: 2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
yeti-platform/yeti#1380 ·