Skip to content

Fix Cryspy recalculation for wrapped Wyckoff coordinates#159

Merged
AndrewSazonov merged 3 commits intomasterfrom
fix-recalc-wyckoff
Apr 27, 2026
Merged

Fix Cryspy recalculation for wrapped Wyckoff coordinates#159
AndrewSazonov merged 3 commits intomasterfrom
fix-recalc-wyckoff

Conversation

@AndrewSazonov
Copy link
Copy Markdown
Member

Fresh Cryspy dictionary creation could wrap fractional coordinates such as -x to 1-x, causing special Wyckoff sites to be inferred as general positions with incorrect multiplicities. This made ed-6.py plots diverge after fit 3 even though fitted parameters looked correct.

The fix normalizes fresh Cryspy dictionaries from the EasyDiffraction structure state and restores atom multiplicities from stored Wyckoff labels. Added a regression test for the wrapped-coordinate case.

@AndrewSazonov AndrewSazonov requested a review from Copilot April 27, 2026 12:58
@AndrewSazonov AndrewSazonov added the [scope] bug Bug report or fix (major.minor.PATCH) label Apr 27, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

❌ Patch coverage is 79.16667% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.29%. Comparing base (6bf3deb) to head (87bb078).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/easydiffraction/analysis/calculators/cryspy.py 79.16% 3 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #159      +/-   ##
==========================================
- Coverage   88.31%   88.29%   -0.03%     
==========================================
  Files         151      151              
  Lines        8698     8722      +24     
  Branches      891      895       +4     
==========================================
+ Hits         7682     7701      +19     
- Misses        722      725       +3     
- Partials      294      296       +2     
Flag Coverage Δ
integration 74.91% <75.00%> (+<0.01%) ⬆️
unittests 79.45% <54.16%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a Cryspy recalculation edge case where freshly-created Cryspy dictionaries normalize fractional coordinates (e.g. -x1-x) and can mis-infer Wyckoff multiplicities, leading to incorrect multiplicities on subsequent recalculations. The PR updates newly created Cryspy dictionaries to match the EasyDiffraction Structure state (including restoring multiplicities from stored Wyckoff letters) and adds a regression test for the wrapped-coordinate case.

Changes:

  • Update CryspyCalculator to re-sync freshly created Cryspy dictionaries with the current EasyDiffraction structure/experiment state.
  • Add Wyckoff-letter-based restoration of atom_multiplicity in the Cryspy model sub-dictionary.
  • Add a regression unit test covering coordinate wrapping and multiplicity restoration; update one tutorial’s chosen minimizer.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/easydiffraction/analysis/calculators/cryspy.py Re-sync fresh Cryspy dictionaries with ED state and restore atom multiplicities from Wyckoff data.
tests/unit/easydiffraction/analysis/calculators/test_cryspy.py Add regression test for wrapped coordinates causing incorrect multiplicity inference.
docs/docs/tutorials/ed-15.py Change tutorial minimizer selection (lmfitbumps) and split into a separate cell.
docs/docs/tutorials/ed-15.ipynb Regenerated notebook content to reflect the updated tutorial script.

Comment thread src/easydiffraction/analysis/calculators/cryspy.py
Comment thread tests/unit/easydiffraction/analysis/calculators/test_cryspy.py
Comment thread docs/docs/tutorials/ed-15.py
@AndrewSazonov AndrewSazonov merged commit 8f9a679 into master Apr 27, 2026
2 checks passed
@AndrewSazonov AndrewSazonov deleted the fix-recalc-wyckoff branch April 27, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[scope] bug Bug report or fix (major.minor.PATCH)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants