Skip to content

Honor explicit zero density in material mixtures - #143

Merged
pkienzle merged 2 commits into
python-periodictable:masterfrom
antonsoo:fix/zero-mixture-density
Oct 23, 2026
Merged

pkienzle merged 2 commits into
python-periodictable:masterfrom
antonsoo:fix/zero-mixture-density

Conversation

@antonsoo

Copy link
Copy Markdown
Contributor

mix_by_weight and mix_by_volume ignore density=0 and natural_density=0, retaining a computed positive density. Their scattering results therefore remain nonzero for a requested vacuum.

Distinguish omitted overrides from zero. Handle zero natural density without evaluating an undefined isotope mass ratio for empty formulas, including zero-quantity mixtures.

Fourteen regressions pass, including ten that fail before. Full tests, doctests and mypy pass on Python 3.10 and 3.12 (131 checks each); the configured strict HTML build passes. Independent material-mixture equations verify the density, composition and downstream scattering results.

The implementation and validation were AI-prepared.

@pkienzle
pkienzle merged commit 9e17ac6 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