Two location guards test presence rather than lock, so alt/az can be computed at 0,0
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
- 78/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Tranquilla
- Stack tecnologico
- python
- Ambito
- embedded-iot
Direzione di ricerca
Inizia con python/PiFinder/calc_utils.py e python/PiFinder/integrator.py, quindi esamina i valori predefiniti di Location e la logica di blocco in python/PiFinder/state.py. Traccia i due punti di chiamata e le relative suite di test; il completamento significa che entrambi rifiutano una posizione non bloccata (e gestiscono None in modo difensivo) senza modificare la truthiness o il comportamento del fuso orario di Location.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Found while verifying the wording for #646 (docs PR #653). Latent — no user-visible symptom today — but the guards do not express what they are trying to express, and the thing masking them is upstream and unrelated.
The problem
Two call sites guard on the presence of a Location when what they need is a locked one.
python/PiFinder/calc_utils.py:243 — calc_object_altitude():
location = shared_state.location()
dt = shared_state.datetime()
if location and dt and solution:
aa = FastAltAz(location.lat, location.lon, dt)
python/PiFinder/integrator.py:493 — _get_alt_az():
if ra_deg is None or dec_deg is None or location is None or dt is None:
return None, None
calc_utils.sf_utils.set_location(location.lat, location.lon, location.altitude)
Why neither guard does anything
Location is a plain @dataclass (state.py:196) with no __bool__ and no __len__, so every instance is truthy. And the field is initialized to a real object, not None:
self.__location: Location = Location() # state.py:295
whose defaults are lat = 0.0, lon = 0.0, lock = False. So if location is always true, and location is None is essentially always false.
The guards therefore reduce to if dt and solution and if ra/dec and dt. A path that sets a datetime without a lock computes alt/az for an observer at 0°N 0°E — Null Island, in the Gulf of Guinea. The result is a plausible-looking number that is wrong by however far the user is from there.
Why nothing breaks today
Both are reached through UI paths already gated on shared_state.altaz_ready() (state.py:332), which does test location.lock. The masking is upstream and incidental — nothing in either function records that it depends on a caller checking lock first.
Suggested fix
Guard on location.lock at both sites, matching altaz_ready(). Defining __bool__ on Location to mean "locked" would make the existing if location read correctly, but that is a wider change with its own trap: if location would then be false for a perfectly valid unlocked Location, and state.py:544 (if self.__location and self.__location.timezone) relies on current truthiness for timezone resolution, which has nothing to do with lock. Explicit location.lock at the two call sites is the smaller and clearer change.
Note set_location() (state.py:471) does assign v unconditionally, so None is technically reachable through it. Keeping a None check alongside a lock check is defensible; testing only for None is not.
- Lingua principale
- Jupyter Notebook
- Stelle
- 253
- Fork
- 63
- Merge medio
- 11h 55m
- PR unite (30g)
- 8
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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 brickbots/PiFinder
-
Discord Link InvalidAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 67/100
brickbots/PiFinder#682 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 1 giorno
-
catalogs enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di brickbots/PiFinder
Issue simili
-
[SoC]: Kirin 9010Apertanew-soc
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
hrw/arm-socs-table#231 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
The clock app crashes on rtcAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/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
-
Arch: all Area: Drivers OS: Linux Type: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
esphome/device-builder#2992 ·
I maintainer di solito rispondono entro 1 giorno