IDAES / examples

IDAES platform examples and tutorials
https://idaes-examples.readthedocs.io
Other
14 stars 34 forks source link

Add Spell Checker #103

Closed bpaul4 closed 2 months ago

bpaul4 commented 2 months ago

Add Spell Checker

Fixes #102

{Description}


Legal Acknowledgement

By contributing to this software project, I agree to the following terms and conditions for my contribution:

I agree my contributions are submitted under the license terms described in the LICENSE.txt file at the top level of this directory.
I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.
andrewlee94 commented 2 months ago

@bpaul4 I went throguh and fixed most/all of the typos in the idaes-examples/mod folder.

ksbeattie commented 2 months ago

I just pushed a bunch of changes, one commit per "correction". Please, more knowledgeable people, review.

FWIW, here's an example of how I did the individual "search and replace" via the macos command line:

sed -i '~' 's/intialization/initialization/g' $(grep -rl intialization)

Edit: Use the w option in the grep here if you want correction to be on a word boundary. It may not always be what is needed but it helps in situations where the misspelled word is part of another correctly spelled word, like:

sed -i '~' 's/compressio/compressor/g' $(grep -rwl compressio)

bpaul4 commented 2 months ago

Thanks @ksbeattie, your commits look good and the regenerated SVG files look good as well. The "search and replace" is an interesting tool to have, can this be done on Windows as well?

ksbeattie commented 2 months ago

Thanks @ksbeattie, your commits look good and the regenerated SVG files look good as well. The "search and replace" is an interesting tool to have, can this be done on Windows as well?

I think it should, though tools like sed and grep are not usually installed on Windows. There are various ways to install them though I'd think that on Windows you're probably using an IDE so your best bet for this would be to use the "search and replace" of "refactor" feature of that IDE.

JavalVyas2000 commented 2 months ago

I believe most of the typos are fixed. Only typos remaining now are because they are either variable and function names (dum, fre and nd), keywords (ser - series) or grammar like Diagnostics should be Diagnostic or a version key spell check.

lbianchi-lbl commented 2 months ago

@bpaul4 After looking at the notebook where the pandas warnings are causing the spellcheck to fail, I think the code that causes the warnings to be emitted may actually be in the notebook itself, even though the word being flagged as a misspelling (ser) is defined elsewhere (most likely within pandas):

image image

So, applying the suggested fix (using float(data["my_column"].iloc[0]) instead of float(data["my_column"])) should cause the warnings, and consequently those spellcheck failures, to go away.

bpaul4 commented 2 months ago

@agarciadiego in the image above from the notebook "Using Parameter Estimation with Modular Property Packages", it appears that in some variables are set to values of float(a dictionary value) and some expressions are defined as float(a dictionary series) - a_model_variable. Would you be able to investigate which are causing the FutureWarnings and push any syntax corrections to this PR?

lbianchi-lbl commented 2 months ago

@agarciadiego in the image above from the notebook "Using Parameter Estimation with Modular Property Packages", it appears that in some variables are set to values of float(a dictionary value) and some expressions are defined as float(a dictionary series) - a_model_variable. Would you be able to investigate which are causing the FutureWarnings and push any syntax corrections to this PR?

@bpaul4 @agarciadiego I've created a dedicated issue to track this separately from this PR: #108.

lbianchi-lbl commented 2 months ago

The spellcheck is now passing, however the notebooks tests are failing because of an AssertionError in active/power_gen/ngcc/ngcc_test.ipynb:

image

I was able to confirm the same failure running locally (Ubuntu 20.04, Python 3.10.14).

Any thoughts on how likely it is that the failure is related to the changes in this PR?

lbianchi-lbl commented 2 months ago

Update: I ran git bisect between 5703f2a (bad) and f62f20fe5 (good) using git bisect run bash -c 'pytest --verbose idaes_examples/notebooks/active/power_gen/ ; status=$? ; git reset --hard ; exit $status' as a "probe". According to this, the commit that introduced the failure is 4b805f3:

4b805f3f04a67e37e0cf3f228d7cdb53a7bdf86d is the first bad commit
commit 4b805f3f04a67e37e0cf3f228d7cdb53a7bdf86d
Author: Andrew Lee <andrew.lee@netl.doe.gov>
Date:   Fri Apr 12 12:20:16 2024 -0400

    Fixing typos in idaes_examples/mod

 .../NETL_32D_gas_phase_thermo.py                   |  6 +++---
 .../NETL_32D_solid_phase_thermo.py                 |  6 +++---
 idaes_examples/mod/dae/petsc/pid_steam_tank.py     |  4 ++--
 idaes_examples/mod/hda/hda_ideal_VLE.py            | 14 +++++++-------
 idaes_examples/mod/methanol/methanol_param_VLE.py  |  4 ++--
 .../mod/methanol/methanol_state_block_VLE.py       |  6 +++---
 idaes_examples/mod/power_gen/SOFC_ROM.py           |  2 +-
 idaes_examples/mod/power_gen/gas_turbine.py        | 22 +++++++++++-----------
 idaes_examples/mod/power_gen/hrsg.py               |  4 ++--
 idaes_examples/mod/power_gen/ngcc.py               |  8 ++++----
 idaes_examples/mod/power_gen/ngcc_soec_costing.py  |  4 ++--
 idaes_examples/mod/power_gen/soec.py               |  6 +++---
 .../properties/thermophysical_property_example.py  |  6 +++---
 13 files changed, 46 insertions(+), 46 deletions(-)
bisect run success

I see that this commit doesn't directly affect the failing notebook idaes_examples/notebooks/active/power_gen/ngcc/ngcc_test.ipynb, but it does make some functional (in the sense of "not non-functional") changes to Python modules in idaes_examples/mod/power_gen, which, based on the naming alone, makes me think they might be related. Any idea on what might be happening?

JavalVyas2000 commented 2 months ago

idaes_examples/mod/power_gen/gas_turbine.py
idaes_examples/mod/power_gen/hrsg.py
idaes_examples/mod/power_gen/ngcc.py

The above are the files used in ngcc flowsheet. I will look into this and let you know.

JavalVyas2000 commented 2 months ago

The commit commit changes a variable name and the model is being initialized from a saved solution which has the incorrect spelling for cap_additional_co2 and I believe this is a reason why there is an assert error.

lbianchi-lbl commented 2 months ago

Thanks @JavalVyas2000 for the tip. I was able to delete the outdated ngcc_init.json.gz and re-run the notebook locally, which resulted in a new file with up-to-date variables being created. All checks are now passing.

bpaul4 commented 2 months ago

Thank you @andrewlee94 @ksbeattie @JavalVyas2000 @lbianchi-lbl for your contributions to this PR. It looks like everything is passing now and all spelling/other issues have been resolved.

bpaul4 commented 2 months ago

@andrewlee94 do you have any further suggestions or requests before we merge this?