Reset chaining context in MeasurementContainer.clear()
Closes #25 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user