-
Notifications
You must be signed in to change notification settings - Fork 23
Fix behavior of PHREEQC equilibrate when composition contains pure elements #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #282 +/- ##
==========================================
+ Coverage 84.78% 84.89% +0.10%
==========================================
Files 9 9
Lines 1466 1476 +10
Branches 255 257 +2
==========================================
+ Hits 1243 1253 +10
Misses 193 193
Partials 30 30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
rkingsbury
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @vineetbansal ! This is a solid start and I think as-is, it should functionally solve the problem. I've made some comments throughout b/c I think there might be a "cleaner" way to accomplish it. Let me know if you have any questions.
|
Thanks - that makes sense, and seems like it will work. So it looks like you're suggesting: a. Save the original amounts per element before equilibrate, say as However, I have a few observations/suggestions if we go this route:
To ask it the question - give the amount of The
it could return All of this method's users also immediately try to parse out the parenthesis anyway, so it will save them some work.
In this I'm assuming that the number of possible missing species after going through Putting all of this together, the code looks like (assume This version does pass the newly introduced tests as well. |
Yes, exactly. (I assume when you said "If its greater" you meant "if its less" - although we should probably just confirm they are equal via.
Yes, or alternatively, I think we can skip the query step and just restore all the Elements to iterate over
This is an excellent point! Although the advantage of checking every element is that it provides additional assurance that mass is conserved (really solving a different problem than the one at issue here - but just in case something strange happened in the wrapper). I suppose would could add a first level check of the total solution mass (so save
|
|
Thanks @rkingsbury - I've opened PR #284 with the changes to the methods. I'll make the necessary tweaks to this one once that one is merged. |
rkingsbury
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good @vineetbansal ! One small change to the log message please.
|
@rkingsbury - hopefully this is what you had in mind all along - in retrospect there's very little code added but it took me a while to get there! |
rkingsbury
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @vineetbansal ! On my final review I found one small (possible) efficiency improvement and would like one tweak to two of the unit tests. Please check those items and then I'm ready to merge!
(Actually, if you could also please add an item to the CHANGELOG I would appreciate it). I will typically edit the text a bit before a release, but having the placeholders there is helpful to make sure I remember all the contributions!
|
@rkingsbury - thanks - your suggestions make sense. I'll remember to edit the CHANGELOG in future PRs. Feel free to change my initial stab at the CHANGELOG entry in case I'm missing something. |
Summary
Major changes:
xfailsto show that the introduced tests do pass with the change.The
atolI chose is totally arbitrary and I'm not sure if it's realistic. Happy to discuss more and introduce changes to this PR!Some other unrelated minor changes seem to have been made by my
pre-commithook.Checklist
ruff. (For guidance in fixing rule violates, see rule list)mypy.Tip: Install
pre-commithooks to auto-check types and linting before every commit: