Reset chaining context in MeasurementContainer.clear()

Closes #25

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Rene De Ren
2026-03-11 15:06:17 +01:00
parent 135dfc31d3
commit 89aec9a7eb
6 changed files with 25 additions and 9 deletions

View File

@@ -270,15 +270,29 @@ class ValidationUtils {
this.logger.warn(`Dimension '${name}' key '${key}' has mismatched x and y lengths. Ignoring this key.`);
return false;
}
// Validate that x values are in ascending order
// Validate that x values are in ascending order — sort if not
else if (!this.isSorted(value.x)) {
this.logger.warn(`Dimension '${name}' key '${key}' has unsorted x values. Sorting...`);
return false;
const indices = value.x.map((v, i) => i);
indices.sort((a, b) => value.x[a] - value.x[b]);
value.x = indices.map(i => value.x[i]);
value.y = indices.map(i => value.y[i]);
}
// Validate that x values are unique
else if (!this.isUnique(value.x)) {
// Validate that x values are unique — remove duplicates if not
if (!this.isUnique(value.x)) {
this.logger.warn(`Dimension '${name}' key '${key}' has duplicate x values. Removing duplicates...`);
return false;
const seen = new Set();
const uniqueX = [];
const uniqueY = [];
for (let i = 0; i < value.x.length; i++) {
if (!seen.has(value.x[i])) {
seen.add(value.x[i]);
uniqueX.push(value.x[i]);
uniqueY.push(value.y[i]);
}
}
value.x = uniqueX;
value.y = uniqueY;
}
// Validate that y values are numbers
else if (!this.areNumbers(value.y)) {