`asarray` with `copy=False` produces new array?
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 50/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- python
- Ambito
- documentation
Direzione di ricerca
Inizia confrontando la formulazione della specifica per asarray e astype con gli esempi nell’issue, quindi verifica come il testo normativo esistente tratta l’identità dell’oggetto rispetto alla memoria condivisa. Il lavoro è completato quando è stato chiarito se copy=False richiede di restituire lo stesso oggetto array e la specifica è resa non ambigua.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 281
- Fork
- 52
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di data-apis/array-api
-
bug Maintenance Narrative Content
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
Maintenance
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
Tutte le issue di data-apis/array-api
Issue simili
-
essnmx good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
-
[Feature] 奇物选择添加优先级 Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
syfoud/Simulated_Scepter#174 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Giskard-AI/giskard-oss#2840 · 1 commento ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Apertaarea: repo bug perceived difficulty: 2
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
yeti-platform/yeti#1380 ·