Skip to content

Conversation

@SuixiongTay
Copy link
Collaborator

@SuixiongTay SuixiongTay commented Jan 20, 2026

Summary

Todos:

@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.43%. Comparing base (07e2d9b) to head (f7d5d3c).
⚠️ Report is 39 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #317      +/-   ##
==========================================
+ Coverage   85.68%   86.43%   +0.75%     
==========================================
  Files          10       14       +4     
  Lines        1607     1851     +244     
  Branches      285      320      +35     
==========================================
+ Hits         1377     1600     +223     
- Misses        194      207      +13     
- Partials       36       44       +8     

☔ 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
Copy link
Member

rkingsbury commented Jan 20, 2026

Very excited to see these, @SuixiongTay ! Before we finalize, please also add the following:

  • Choose just one representative ion for each preset. (For the paper analysis, it's good that you've evaluated multiple, but for purposes of distributing to the community we need to use our judgment and pick one)
  • Update the type annotation and docstring of from_preset with the new preset names and descriptions
  • Expand test_from_preset to test that 1) all newly added presets can successfully create a Solution and 2) pick 1 or two presets and check specific characteristics (e.g., verify correct pH, TDS, or selected ion concentrations)

@rkingsbury rkingsbury changed the title Adding YAML presets from WW project Solution.from_preset: Add representative industrial wastewaters Feb 5, 2026
@rkingsbury
Copy link
Member

Hi @SuixiongTay , thanks for these updates. It looks like the automatic tests are getting stuck on test_from_preset , specifically the [ash] preset. Is that test working for you locally? I'm wondering if we've accidentally created some kind of race condition or infinite loop.

@rkingsbury
Copy link
Member

Small edit - in the References in the docstring, please expand the preprint DOI into a full biobliographic reference (authors, title, preprint available on Research Square"

@rkingsbury
Copy link
Member

Hi @SuixiongTay , thanks for these updates. It looks like the automatic tests are getting stuck on test_from_preset , specifically the [ash] preset. Is that test working for you locally? I'm wondering if we've accidentally created some kind of race condition or infinite loop.

Also, make sure to update your branch with git pull origin main to ensure you're testing against the latest code in all cases.

@SuixiongTay
Copy link
Collaborator Author

Hi @SuixiongTay , thanks for these updates. It looks like the automatic tests are getting stuck on test_from_preset , specifically the [ash] preset. Is that test working for you locally? I'm wondering if we've accidentally created some kind of race condition or infinite loop.

Yes, it is running correctly for me locally, although the pytest is relatively slow.

From the Cl log it looks like the Cl ran into a wall-time limit. One other work around would be to reduce the processing time either by 1) using their elemental compositions/proportions or 2) defining a threshold for the fully speciated ions which should help speed up the workflow.

If the first approach makes sense, I can update the yaml file accordingly.

test_solution.py::test_from_preset[ash] PASSED                               [  3%]
test_solution.py::test_from_preset[batt_mfg] PASSED                          [  3%]
test_solution.py::test_from_preset[batt_recycling] PASSED                    [  3%]
test_solution.py::test_from_preset[coal_washing] PASSED                      [  4%]
test_solution.py::test_from_preset[CRL] PASSED                               [  4%]
test_solution.py::test_from_preset[drilling] PASSED                          [  4%]
test_solution.py::test_from_preset[excavation] PASSED                        [  4%]
test_solution.py::test_from_preset[FGD] 

Copy link
Member

@rkingsbury rkingsbury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @SuixiongTay see these comments for some ideas about how to streamline the unit testing here

Comment on lines 875 to 885
# test invalid preset
with pytest.raises(FileNotFoundError):
Solution.from_preset("nonexistent_preset")
# test json as preset
json_preset = tmp_path / "test.json"
dumpfn(solution, json_preset)
solution_json = Solution.from_preset(tmp_path / "test")
assert isinstance(solution_json, Solution)
assert solution_json.temperature.to("degC") == ureg.Quantity(data["temperature"])
assert solution_json.pressure == ureg.Quantity(data["pressure"])
assert np.isclose(solution_json.pH, data["pH"], atol=0.01)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are now parameterizing this entire test to run on multiple presets, this part of the test should be broken into a separate test, because it doesn't need to be run multiple times.

(these lines don't have anything to do with the specific preset file; they are testing behavior with unrecognized file names and custom files)

Comment on lines 873 to 874
for solute in solution._solutes:
assert solute in data["solutes"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of iterating, it will probably be much faster to compare the contents of the entire list at once, e.g.

assert set(solution._solutes) == set(data["solutes"]

This should ensure that every solute in the yaml is present in the solution

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that converting the list to a set is necessary b/c lists comparisons are ordered, but sets are not. An alternative would be to sort the lists first

assert isinstance(solution, Solution)
assert solution.temperature.to("degC") == ureg.Quantity(data["temperature"])
assert solution.pressure == ureg.Quantity(data["pressure"])
assert np.isclose(solution.pH, data["pH"], atol=0.01)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the atol here to 0.001; I can't think of a reason why we shouldn't be able to achieve that precision

Comment on lines +838 to +860
"seawater",
"ash",
"batt_mfg",
"batt_recycling",
"coal_washing",
"CRL",
"drilling",
"excavation",
"FGD",
"flotation",
"flue_gas",
"gasification",
"geothermal",
"leachate",
"mine_drainage",
"mine_tailings",
"plating",
"pw_conv",
"pw_unconv",
"refining",
"semiconductor",
"smelting",
"tanning",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary to test every preset; let's comment out all except for seawater and perhaps 2 others that have different compositions

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