ENH: allow user-DType promoters that only apply to an explicitly requested output DType
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Start in numpy/_core/src/umath/dispatching.cpp at resolve_implementation_info and trace how promoter patterns match when the output DType is unspecified versus explicitly requested. The issue leaves two possible designs open and notes compatibility concerns, so first investigate existing matching behavior and registrations. Done means a chosen approach allows output-keyed user-DType promoters to work for explicit output requests without unexpectedly changing calls that omit an output DType.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Proposed new feature or change
A user DType cannot register a promoter for "inputs of any DType, output explicitly requested as my DType" (np.add(f64, f64, dtype=MyDType)) without also changing NumPy's own promotion.
In resolve_implementation_info (numpy/_core/src/umath/dispatching.cpp), an unspecified output matches any pattern:
if (given_dtype == NULL) {
if (i >= nin) {
/* Unspecified out always matches (see below for inputs) */
continue;
So a promoter registered for (PyArrayDescr_Type, PyArrayDescr_Type, MyDType) matches every call where no output DType is given. For numpy-quaddtype, registering such a promoter for add makes
np.array([1.0, 2.0], dtype=np.longdouble) + 1.0
return a QuadPrecDType array instead of np.longdouble, as soon as the package is imported. Today the only safe rule is the one from numpy/numpy-quaddtype#76: every promoter needs a user-DType input. As a result, this fails:
np.add(np.array([1.0, 2.0]), np.array([3.0, 4.0]), dtype=QuadPrecDType)
UFuncTypeError: ufunc 'add' did not contain a loop with signature matching types (<class 'numpy.dtypes.Float64DType'>, <class 'numpy.dtypes.Float64DType'>) -> <class 'numpy_quaddtype.QuadPrecDType'>
NumPy's own dtypes support this case, e.g. np.add(f32, f32, dtype=np.float64).
Possible directions:
- When the output DType is not given, it does not match a pattern that names a concrete output DType. Only abstract or
Noneoutputs match, so output-keyed promoters apply only when the user passeddtype=/signature=. - Let a promoter decline (e.g. return a sentinel), so dispatch continues with the remaining candidates. This is the "trusting promoters to do nothing" idea from numpy/numpy-quaddtype#76.
Option 1 may change matching for existing registrations, so it may need care or opt-in.
- Lingua principale
- Python
- Stelle
- 33.5k
- Fork
- 13.1k
- Merge medio
- 1g 19h
- PR unite (30g)
- 143
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi 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 numpy/numpy
-
00 - Bug component: numpy.linalg
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
00 - Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
00 - Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
numpy/numpy#33422 · 6 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
BUG: f2py treats a backslash as an escape inside character literalsForse già presa @HaoZeke l’ha presa 17 giorni fa. Aperta00 - Bug component: numpy.f2py
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
numpy/numpy#33220 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
DOC: use CITATION.cff file format for citation informationForse già presa @JaroCamphuijsen l’ha presa 58 giorni fa. Aperta04 - Documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
numpy/numpy#32817 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
521xueweihan/HelloGitHub#4543 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
emeryberger/CSrankings#15700 ·
I maintainer di solito rispondono entro 2 giorni
-
Bug | 工作不正常 Triage | 待检查
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
OneDragon-Anything/ZenlessZoneZero-OneDragon#3084 ·
I maintainer di solito rispondono entro 1 giorno
-
Task select patterns with uppercase letters never matchForse già presa @manobhisriram l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno