Skip to content

Keep same-atom substitutions unchanged - #142

Merged
pkienzle merged 1 commit into
python-periodictable:masterfrom
antonsoo:fix/isotope-self-replacement
Oct 23, 2026
Merged

pkienzle merged 1 commit into
python-periodictable:masterfrom
antonsoo:fix/isotope-self-replacement

Conversation

@antonsoo

Copy link
Copy Markdown
Contributor

formula("H2O", density=1).replace(H, H) currently produces O. With portion=0.5, it produces H1.5O. This changes the original-material control in a generic isotope-label sweep.

Skip the atom-count update when source and target are identical, while still returning a separate formula.

Sixteen regression cases pass, including twelve that fail before. Full tests, doctests and mypy pass on Python 3.10 and 3.12 (133 checks each); the configured strict HTML build passes. Material and protein label sweeps also agree with independent composition and scattering equations.

The implementation and validation were AI-prepared.

@pkienzle
pkienzle merged commit c84e81f into python-periodictable:master Oct 23, 2026
6 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