fix: stabilize localization comparison semantics

This commit is contained in:
2026-08-28 20:57:13 +09:00
parent 9b9244be85
commit e8dac792d9
10 changed files with 340 additions and 31 deletions
+34
View File
@@ -555,6 +555,19 @@ function validateResultRelationships(value, context = {}) {
}
const sourceIds = new Set(context.scene?.sources?.map((source) => source.id) ?? []);
const expectedBandIds = new Set(context.experiment?.frequencyBands?.map((band) => band.id) ?? []);
const resultAlgorithm = value.algorithm ?? context.experiment?.beamforming?.algorithm;
const expectedRawScale =
resultAlgorithm === "das"
? "power"
: resultAlgorithm === "das-phat" || resultAlgorithm === "gcc-phat"
? "score"
: undefined;
const expectedBeamSpreadMethod =
expectedRawScale === "power"
? "connected-half-power-power-weighted-covariance"
: expectedRawScale === "score"
? "connected-half-maximum-score-weighted-covariance"
: undefined;
const bandIds = [];
if (Array.isArray(value.bands)) {
value.bands.forEach((band, bandIndex) => {
@@ -576,12 +589,33 @@ function validateResultRelationships(value, context = {}) {
});
if (isRecord(band.rawMap) && !["power", "score"].includes(band.rawMap.scale)) {
addIssue(issues, `${path}.rawMap.scale`, "rawMap은 power 또는 score scale이어야 합니다.");
} else if (
isRecord(band.rawMap) &&
expectedRawScale &&
band.rawMap.scale !== expectedRawScale
) {
addIssue(
issues,
`${path}.rawMap.scale`,
`${resultAlgorithm} 결과의 rawMap scale은 ${expectedRawScale}여야 합니다.`,
);
}
if (Array.isArray(band.peaks)) {
band.peaks.forEach((peak, peakIndex) => {
if (peak?.sourceId && sourceIds.size > 0 && !sourceIds.has(peak.sourceId)) {
addIssue(issues, `${path}.peaks[${peakIndex}].sourceId`, "장면에 없는 source id입니다.");
}
if (
expectedBeamSpreadMethod &&
isRecord(peak?.beamSpread) &&
peak.beamSpread.method !== expectedBeamSpreadMethod
) {
addIssue(
issues,
`${path}.peaks[${peakIndex}].beamSpread.method`,
`${expectedRawScale} map과 맞는 beamSpread method여야 합니다.`,
);
}
});
}
});