Skip to content

fix: prevent negative CShM values and NaN RMSD display for perfect ge…#95

Merged
HenriqueCSJ merged 1 commit into
mainfrom
claude/fix-qshape-gui-results-SjlwA
Jan 17, 2026
Merged

fix: prevent negative CShM values and NaN RMSD display for perfect ge…#95
HenriqueCSJ merged 1 commit into
mainfrom
claude/fix-qshape-gui-results-SjlwA

Conversation

@HenriqueCSJ

Copy link
Copy Markdown
Owner

…ometries

The CShM calculation could produce slightly negative values (e.g., -0.0000) for perfect octahedral geometries due to floating-point precision errors when overlapNorm exceeded 1.0. This caused:

  1. CShM displaying as "-0.0000" instead of "0.0000"
  2. RMSD showing "NaN" (sqrt of negative number)

Fixes:

  • Clamp overlapNorm to [-1, 1] in shapeCalculator.js to prevent overflow
  • Add Math.max(0, ...) to ensure CShM is never negative
  • Add safeguards in qualityMetrics.js for RMSD calculation
  • Update all display components to handle edge cases with Math.max(0, ...) and Number.isFinite() checks

…ometries

The CShM calculation could produce slightly negative values (e.g., -0.0000)
for perfect octahedral geometries due to floating-point precision errors
when overlapNorm exceeded 1.0. This caused:
1. CShM displaying as "-0.0000" instead of "0.0000"
2. RMSD showing "NaN" (sqrt of negative number)

Fixes:
- Clamp overlapNorm to [-1, 1] in shapeCalculator.js to prevent overflow
- Add Math.max(0, ...) to ensure CShM is never negative
- Add safeguards in qualityMetrics.js for RMSD calculation
- Update all display components to handle edge cases with Math.max(0, ...)
  and Number.isFinite() checks
@HenriqueCSJ HenriqueCSJ merged commit 0270992 into main Jan 17, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants