ck 4
Dependencies
- [2]
GE3VNRXLck 2 - [3]
LQLC7S3Atrying gemini: Inconsistent Standards in @utils/ refactoring - [4]
KZKLAINJrun out of space on nest, cleaned out - [5]
2HAQZPV3more refactoring with glm - [6]
2P27XV3Dfixed cyclo over 30 - [7]
DS22DKV3added shell script integration tests. - [*]
JZRF7OBJrefactor to get db omports out of utils, but still have failing tests, may need updating
Change contents
- replacement in utils/spectrogram.go at line 113
func normalizeFlat(power []float64, rows, cols int) [][]uint8 {if rows == 0 || cols == 0 {return nil}// Pass 1: find minNonZero, then convert power to dB in-place, tracking min/max dB// convertToDB replaces power values with dB values in-place, returning min/max dB.// Zero/negative values are clamped to minNonZero before conversion.func convertToDB(power []float64) (minDB, maxDB float64) { - replacement in utils/spectrogram.go at line 123
minNonZero = 1e-20 // fallback floorminNonZero = 1e-20 - replacement in utils/spectrogram.go at line 126
minDB := math.MaxFloat64maxDB := -math.MaxFloat64minDB = math.MaxFloat64maxDB = -math.MaxFloat64 - edit in utils/spectrogram.go at line 141
return minDB, maxDB} - replacement in utils/spectrogram.go at line 144
// Pass 2: normalize dB to uint8 and write into result (with vertical flip)func normalizeFlat(power []float64, rows, cols int) [][]uint8 {if rows == 0 || cols == 0 {return nil}minDB, maxDB := convertToDB(power)// Normalize dB to uint8 and write into result (with vertical flip) - edit in utils/spectrogram.go at line 158
// Allocate result with flat backing slice (single allocation) - edit in utils/spectrogram.go at line 161
// Flip: row i in result gets data from row (rows-1-i) in power - replacement in utils/mapping.go at line 128[3.485]→[3.485:623](∅→∅),[3.623]→[3.92843:93015](∅→∅),[3.92843]→[3.92843:93015](∅→∅),[3.93015]→[3.22046:22196](∅→∅),[3.22196]→[3.93015:93395](∅→∅),[3.93015]→[3.93015:93395](∅→∅)
func collectMappedLabels(mapping MappingFile, dataCalltypes map[string]map[string]bool) (map[string]bool, map[string]map[string]string) {mappedSpeciesSet := make(map[string]bool)mappedCalltypes := make(map[string]map[string]string) // dbSpecies -> dbCalltype -> dataCalltypefor _, sm := range mapping {// Skip sentinel values — they are never looked up in the DBif sm.Species == MappingNegative || sm.Species == MappingIgnore {continue}mappedSpeciesSet[sm.Species] = true// Track calltype mappingsif len(sm.Calltypes) > 0 {if mappedCalltypes[sm.Species] == nil {mappedCalltypes[sm.Species] = make(map[string]string)}for dataCT, dbCT := range sm.Calltypes {mappedCalltypes[sm.Species][dbCT] = dataCT}}}// Also collect unmapped calltypes (where .data calltype = DB calltype)// collectUnmappedCalltypes adds calltypes from .data files that have no explicit// mapping entry (dataCT == dbCT by convention) to the mappedCalltypes set.func collectUnmappedCalltypes(mapping MappingFile, dataCalltypes map[string]map[string]bool, mappedCalltypes map[string]map[string]string) { - replacement in utils/mapping.go at line 134
continue // Already reported as missing speciescontinue - edit in utils/mapping.go at line 139
// If no explicit mapping, assume dataCT == dbCT - edit in utils/mapping.go at line 152
}func collectMappedLabels(mapping MappingFile, dataCalltypes map[string]map[string]bool) (map[string]bool, map[string]map[string]string) {mappedSpeciesSet := make(map[string]bool)mappedCalltypes := make(map[string]map[string]string) - edit in utils/mapping.go at line 158
for _, sm := range mapping {if sm.Species == MappingNegative || sm.Species == MappingIgnore {continue}mappedSpeciesSet[sm.Species] = trueif len(sm.Calltypes) > 0 {if mappedCalltypes[sm.Species] == nil {mappedCalltypes[sm.Species] = make(map[string]string)}for dataCT, dbCT := range sm.Calltypes {mappedCalltypes[sm.Species][dbCT] = dataCT}}}collectUnmappedCalltypes(mapping, dataCalltypes, mappedCalltypes) - edit in CHANGELOG.md at line 81
### Complexity reductions (Stream 6)**tui.Model.View** (14→7): Extracted `renderHeader`, `renderProgressBar`,`renderSegmentInfo`, and `renderLabels` helper methods from the monolithicView function.**utils/normalizeFlat** (14→6): Extracted `convertToDB` helper that findsminNonZero, converts power values to dB in-place, and returns min/max dB. - edit in CHANGELOG.md at line 91[2.8674][9.7568]
**utils/collectMappedLabels** (13→8): Extracted `collectUnmappedCalltypes`helper that adds calltypes from .data files with no explicit mapping entry.