NumPy NDArray typing conflict with numpydoc for `np.integer`.

Aperta
#633 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
numpy, python

Direzione di ricerca

Inizia in numpydoc/validate.py, intorno alla gestione di PR06 alla riga 744, quindi esamina l’issue 341 e la pull request 347 collegati per verificare l’eccezione esistente per le parentesi graffe. Conferma come appare np.integer nell’esempio di annotazione e definisci il completamento come una tipizzazione NumPy valida in cui integer non attiva più PR06.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Why:
Numpydoc ought to support annotations matching the typing functionality of numpy.typing and the built-in scalar types.

What:
I am using NumPy 2.3.0, and numpydoc 1.8.0.
I was writing some typed code using the NDArray dtype specifications, and found numpydoc would raise PR06 for the 'integer' keyword found in the scalar in-built numpy dtype integer.

import numpy as np, numpy.typing as npt
a : npt.NDArray[np.floating | np.integer]

When writing docstrings for such typing, numpydoc throws a PR06 error, due to the inclusion of the integer string.

Parameter "a" type should use "int" instead of "integer"

What I expected:
In the context of using numpy.typing and np.integer, I didn't expect to see numpydoc raise an error for a valid numpy in-build scalar datatype.

How we might solve this:
Either numpy / numpy.typing ought to be using the same rules (i.e. int instead of integer, float instead of floating etc) to represent the in-built dtypes, or (more likely) numpydoc should accommodate this labeling?

I also noticed we added an exclusion case for PR06 via skipping over the "{" character, for option sets defined by braces/curly-brackets in this issue / PR.

Lingua principale
Python
Stelle
354
Fork
185
Merge medio
4m
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di numpy/numpydoc

Tutte le issue di numpy/numpydoc

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.