Skip to content

fix: fix Structure loading with close-duplicate atom - #183

Open
stevenhua0320 wants to merge 1 commit into
diffpy:v3.4.0from
stevenhua0320:fix-close-duplicate-atom
Open

stevenhua0320 wants to merge 1 commit into
diffpy:v3.4.0from
stevenhua0320:fix-close-duplicate-atom

Conversation

@stevenhua0320

Copy link
Copy Markdown
Contributor

@sbillinge ready to review. This is the potential solution proposed by @Tieqiong last summer diffpy/diffpy.pdfgui#291. We change the order of the source that we trust most as the priority. After this is merged and released, we could ask whether this fix would solve this by asking people to test it.

@codecov

codecov Bot commented Mar 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.19%. Comparing base (991889b) to head (dc1b007).
⚠️ Report is 23 commits behind head on v3.4.0.

Additional details and impacted files
@@            Coverage Diff             @@
##           v3.4.0     #183      +/-   ##
==========================================
+ Coverage   99.17%   99.19%   +0.01%     
==========================================
  Files          15       15              
  Lines        2439     2489      +50     
==========================================
+ Hits         2419     2469      +50     
  Misses         20       20              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sbillinge sbillinge left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we need good tests for this. @stevenhua0320 we may want to work with Tieqiong to get a cif file that is not working currently so we can test that it works correctly after the fix.

@sbillinge sbillinge added this to the 3.5.0 release milestone Mar 16, 2026
@sbillinge

Copy link
Copy Markdown
Contributor

@stevenhua0320 I am moving this to the 3.5.0 release as I want this to be fixed carefully and with excellent tests. Actually, it is an important fix, so it would be good if you were interested in working with @cadenmyers13 to write good tests and then to put in a fix, but we don't need to hold up 3.4.0 for this.

@cadenmyers13

Copy link
Copy Markdown
Contributor

@stevenhua0320 Im happy to help with writing a test for this. LMK when you want to

@CAOShurong

Copy link
Copy Markdown

I checked a related origin-setting case from diffpy/diffpy.srfit#213. A shifted copy of the bundled silicon CIF contains a complete list of 192 symmetry operations and a valid H–M symbol. Current main and #183 applied to current main both expand it to 32 sites, with a first calculated PDF peak at 1.92 Å. Keeping the explicit operations gives 8 sites and the same 2.35 Å peak as the unshifted control.

A compact parser regression is a P 2 CIF with operations x,y,z and 1/2-x,y,-z, and a single site at (1/4, 0, 0). The site lies on the shifted twofold axis, so it should remain one site. The identifier fallback currently adds a second site at (3/4, 0, 0). This exercises the explicit-operation fallback alongside the H–M versus IT-number priority in this PR.

@sbillinge

sbillinge commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for reporting that @CAOShurong

@stevenhua0320 please could you implement the regression test suggested by @CAOShurong and reproduce it? We should discuss the right behavior we want to use. This example points out that we don't use the symmetry operations coded into the file. I think this was on purpose, because it is more error prone, so we use tabulated symmetry operations for the spacegroup. These issues point out that when an unconventional origin is used, but the CIF generator coded the corrected symmetry operations in the file, we silently ignore them and get the wrong structure as a result. It is a big change to move the default behavior to reading the hard-coded symmetry operations first and falling back to tabulated ones, and I suspect there are quite a few faulty CIFs out there that would be working and now break if we did that. One option is to set some kind of flag so the default behavior is unchanged but can be overridden. This seems the gentlest. It won't solve the issue that @Tieqiong had oringially when he was trying to read CIF files at scale from a database, though it would give him a route to trouble-shooting the problem because if he found atoms too close to each other, he could maybe retry the CIF read using the hard-coded symmetry operations, something like that?

@sbillinge

Copy link
Copy Markdown
Contributor

also, @stevenhua0320, since the fix that Tieqiong proposed didn't work, I suggest that we revert that one too.

This branch has not been deployed

No deployments
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.

4 participants