feat(core): Protected Band record model, optional JSON key, L17/L18 validation, count helper (ticket 43) #42
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ykp/gensig!42
Loading…
Reference in a new issue
No description provided.
Delete branch "protected-bands-core"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Round 9 W1 — the data layer for protected bands (spec §3.4, §4.2.5, §7.1 L17/L18 are the authority, merged as #41).
Model (
gensig/core/model.py)ProtectedBandfrozen record:Fmin/Fmax(absolute RF MHz),Transition(MHz),Rejection(dB) + the derivedcut_low_mhz/cut_high_mhz— the remez shape deduced from the record (cut span[Fmin−tr, Fmax+tr], §3.4)ProjectData.ProtectedBandsproperty: sorted byFminon assignment, the same assignment conventions asFrequencyBands(TypeError for non-iterables, ValueError coercion messages carrying the cause);reset()clears; edits mark dirty"ProtectedBands"project-JSON key: missing →[](old files load), full round-trip, saved always (matchesFrequencyBands)Validation (
gensig/core/validation.py)L17_PROTECTED_BAND_RECORD:Fmin < Fmax;Transition > 0;Rejection ∈ [10, 120]dB (boundaries legal); band within the instrument range — message carries the record index (ProtectedBands[1])L18_PROTECTED_BAND_OVERLAP: cut spans (transitions included) must be pairwise disjoint — half-open touching is legal; overlap with the signal's own bands is allowed and expected (that's the feature); degenerate records skip the L18 pass so no false positives stack on L17generation_allowedblocks Generatecount_protected_in_span(§4.2.5 label rule): records whose band overlaps[fc − BW/2, fc + BW/2]; transition-only reach does NOT count (the label reflects protected bands, not cut skirts)Tests
tests/test_protected_bands.py(22 tests): record model/cut span, 4-key requirement, coercion, sort-on-assign, JSON round-trip + optional-key tolerance, reset/dirty, the L17 matrix, the L18 matrix (overlap/touching/transitions-collide/signal-band-overlap-allowed), and the count helper (inside/straddle/outside/transition-only/empty).test_model.py'sto_dictkey-set premise gains the new key.Gate
pytest: 1261 passed / 63 skipped, coverage 95.42 %ruff+mypy: cleanNext: ticket 44 — the remez notch stage + global settings (W2).