Skip to content

from_file: address subtle volume bug#347

Merged
rkingsbury merged 6 commits intomainfrom
bugfix
Feb 12, 2026
Merged

from_file: address subtle volume bug#347
rkingsbury merged 6 commits intomainfrom
bugfix

Conversation

@rkingsbury
Copy link
Copy Markdown
Member

@rkingsbury rkingsbury commented Feb 12, 2026

Summary

Solution.from_dict contains logic to ensure that the volume of the Solution that is created is exactly equal to that stored in the dictionary. Small differences can arise in the event that, for example, equilibrate() was called on the original solution and updated the volume. This might result in a slightly final volume than what would be calculated on __init__.

Solution.from_file, which is used by from_preset, did not contain this logic in the case of loading yaml files. For json files, loadfn calls from_dict internally, so the volume adjusting logic was used.

For example, loading the seawater preset prior to this PR resulted in a slight change in volume:

FAILED tests/test_solution.py::test_from_preset[seawater] - AssertionError: assert <Quantity(1.0080611297182314, 'liter')> == <Quantity(1.0080615264452506, 'liter')>

This PR adds the subtle volume correction to from_file (for YAML files) and makes several improvements to the associated unit tests.

@rkingsbury rkingsbury added the fix Bug Fixes label Feb 12, 2026
Updated volume assertions to compare magnitudes for accuracy.
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.31%. Comparing base (e29b282) to head (10354e3).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #347   +/-   ##
=======================================
  Coverage   86.31%   86.31%           
=======================================
  Files          14       14           
  Lines        1856     1856           
  Branches      322      322           
=======================================
  Hits         1602     1602           
  Misses        208      208           
  Partials       46       46           

☔ 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.

@rkingsbury rkingsbury merged commit 30e2df7 into main Feb 12, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant