A malformed noise_model line is reported as "noise_model is not a valid configuration key", and every config parse error reports the line before the right one

Aperta Adatta ai principianti
#1,033 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Inizia da pybnf/parse.py: esamina il ciclo di parsing della configurazione intorno alla riga 876 e i rami degli hint di formato intorno alla riga 1359, poi cerca test del parser che coprano valori di configurazione malformati. Riproduci il problema con examples/tutorial/36_estimate_noise/estimated_sigma.conf usando la riga noise_model malformata dell’issue. Il lavoro è completato quando gli errori identificano la riga corretta, numerata a partire da 1, distinguono le chiavi sconosciute dai valori non validi per chiavi note e i test coprono questi casi.

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

Descrizione

bug minor

Writing a fixed noise level as a bare number is an easy mistake:

noise_model = normal, sigma = 4

The correct form is sigma = fix_at 4. PyBNF reports the mistake as

Error: Parsing configuration key 'noise_model' on line 42.
noise_model is not a valid configuration key.

Both parts of the message are wrong.

  1. noise_model is a valid key. The value is what failed to parse. In pybnf/parse.py, after a line fails the grammar, a chain of elif key == ... branches picks a format hint for the key. A key with no branch falls through to fmt == '' and gets "is not a valid configuration key". The comment on the data branch (around line 1359) describes this same problem for data and fixes it for that one key only. noise_model has no branch, and neither does any other real key not in the chain.

  2. The line number is off by one. With the reproduction below, the noise_model line is line 43 of the file (grep -n agrees), and the message says 42. The number is the index i from for i, line in enumerate(ls) (around line 876), which counts from 0. Every message built from it, including the Misconfigured config key ... at line: {i} text, points at the line before the one at fault.

Reproduction: in examples/tutorial/36_estimate_noise/estimated_sigma.conf, replace the noise_model line with noise_model = normal, sigma = 4, delete the loguniform_var = noise_level ... line, and run pybnf -c on it.

Suggested fix: report a line number counted from 1. When the key is a real configuration key but its value does not parse, say so and give the accepted forms, as the data branch does. Use "is not a valid configuration key" only for a key PyBNF does not know. A test that runs every known key with a malformed value through the parser would keep the next new key from falling through.

Lingua principale
Python
Stelle
25
Fork
25
Merge medio
4h 5m
PR unite (30g)
10

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 lanl/PyBNF

Tutte le issue di lanl/PyBNF

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.