Skip to content

Fix XAS.stitch in XAFS mode when called on the EXAFS spectrum - #4792

Closed
rpinho wants to merge 1 commit into
materialsproject:mainfrom
rpinho:fix-xas-stitch-exafs-caller
Closed

rpinho wants to merge 1 commit into
materialsproject:mainfrom
rpinho:fix-xas-stitch-exafs-caller

Conversation

@rpinho

@rpinho rpinho commented Nov 18, 2026

Copy link
Copy Markdown

XAS.stitch works out which of self and other is the XANES spectrum, but the XANES cut index is computed as xanes.k.index(min(self.k, ...)), which searches the caller's k grid. When the caller is the EXAFS spectrum the selected k value is not in xanes.k, so exafs.stitch(xanes, mode="XAFS") raises ValueError: 2.982941876290979 is not in list on the LiCoO2 test spectra, while xanes.stitch(exafs, mode="XAFS") works. The patch searches xanes.k. test_stitch_xafs now stitches in both orders and checks that the results are the same.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N

@shyuep

shyuep commented Nov 18, 2026

Copy link
Copy Markdown
Member

Automated PR review generated by Claude (posted from @shyuep's account). Based on code and CI status only, nothing was run. Please sanity-check before acting.

CI: zero checks reported. The Lint and test runs for 9327864 are in action_required; a maintainer must approve them.

Good:

  • One-token fix for a real asymmetry: xanes.k.index(min(self.k, ...)) searched the caller's grid, so exafs.stitch(xanes, mode="XAFS") looked up an EXAFS k value in the XANES grid and raised.
  • The test stitches in both orders and requires identical x/y; assert_allclose is already imported in tests/analysis/xas/test_spectrum.py.

Substantive: none.

Nits: none. (Checked the L23 branch: it resolves l2_xanes/l3_xanes by edge up front, so it does not have the same order dependence.)

@shyuep shyuep closed this Nov 19, 2026
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