Skip to content
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

Test case for IWater and PWater subroutines #151

Merged
merged 3 commits into from
Apr 23, 2024

Conversation

austinorr
Copy link
Contributor

Revisions include:

  • remove ACIDPH.py from importable modules -- this module looks like its under construction so it's been staged as a text file temporarily.
  • code coverage cannot be measured for jit-compiled functions or classes. This is ok though because numba code is also valid python code -- except for the special cases in the jitclass(spec) when we are spec'ing another jit class. To get past this barrier quickly I've just checked to see if we're running tests with the flag NUMBA_DISABLE_JIT=1. If set to one (jit disabled), we use the python class in the spec, if not we default to using the jitclass.
  • Added a test case and a helper function to eliminate the .h5 file intermediary (using version controllable json for now instead -- open to discussion on how to make this harder/better/faster/stronger)
  • no additional dependencies for now, but running the tests and measuring coverage is done with pytest and coverage like so:
(hsp2) aorr@POR-AORR:~/wsl-sources/HSPsquared$ NUMBA_DISABLE_JIT=1 coverage run --branch -m  pytest tests/ipwater  && coverage report
=========================================================== test session starts ============================================================
platform linux -- Python 3.11.5, pytest-7.4.3, pluggy-1.3.0
rootdir: /home/aorr/wsl-sources/HSPsquared
collected 2 items                                                                                                                          

tests/ipwater/test_ipwater.py ..                                                                                                     [100%]

============================================================ 2 passed in 0.45s =============================================================
Name                            Stmts   Miss Branch BrPart  Cover
-----------------------------------------------------------------
HSP2/ADCALC.py                    155    141     76      0    10%
HSP2/ATEMP.py                      27     19      4      0    32%
HSP2/CONS.py                      154    143     54      0     6%
HSP2/COPY.py                       18     10      2      0    40%
HSP2/GENER.py                     104     70     20      0    27%
HSP2/GQUAL.py                    1136   1116    454      0     2%
HSP2/HTRCH.py                     309    296    102      0     4%
HSP2/HYDR.py                      477    455    196      0     4%
HSP2/IQUAL.py                     182    173     58      0     5%
HSP2/IWATER.py                    199     52     72     14    70%
HSP2/IWTGAS.py                    116    104     36      0     9%
HSP2/NUTRX_Class.py               592    564    222      0     5%
HSP2/OXRX_Class.py                141    127     32      0     9%
HSP2/PHCARB_Class.py              130    117     32      0     9%
HSP2/PLANK_Class.py               960    914    334      1     5%
HSP2/PQUAL.py                     264    252     74      0     4%
HSP2/PSTEMP.py                    145    136     58      0     5%
HSP2/PWATER.py                    534    154    168     34    68%
HSP2/PWTGAS.py                    269    256     92      0     4%
HSP2/RQUAL.py                     349    330    182      0     4%
HSP2/RQUAL_Class.py               719    698    168      1     3%
HSP2/RQUTIL.py                     24     17     12      0    36%
HSP2/SEDMNT.py                    152    143     52      0     5%
HSP2/SEDTRN.py                    725    708    192      0     3%
HSP2/SNOW.py                      446    433    156      0     3%
HSP2/SOLIDS.py                     92     84     36      0     8%
HSP2/SPECL.py                       4      1      2      0    83%
HSP2/__init__.py                    4      0      0      0   100%
HSP2/configuration.py              41     13      0      0    68%
HSP2/main.py                      291    277    144      0     3%
HSP2/mainDoE.py                   194    175     90      0     7%
HSP2/state.py                     117     90     26      0    20%
HSP2/uci.py                        14     10      0      0    29%
HSP2/utilities.py                 318    256    224      5    14%
HSP2IO/io.py                       48     34     10      0    24%
HSP2IO/protocols.py                32      6     10      0    86%
_version.py                         1      0      0      0   100%
tests/__init__.py                   0      0      0      0   100%
tests/ipwater/__init__.py           0      0      0      0   100%
tests/ipwater/test_ipwater.py      46      0     16      0   100%
-----------------------------------------------------------------
TOTAL                            9529   8374   3406     55    11%

This shows the ~70% coverage for HSP2/IWater and HSP2/PWater modules.

We can also run the suite with the numba jit to ensure we didn't break anything.

(hsp2) aorr@POR-AORR:~/wsl-sources/HSPsquared$ coverage run --branch -m  pytest tests/ipwater  && coverage report
=========================================================== test session starts ============================================================
platform linux -- Python 3.11.5, pytest-7.4.3, pluggy-1.3.0
rootdir: /home/aorr/wsl-sources/HSPsquared
collected 2 items                                                                                                                          

tests/ipwater/test_ipwater.py ..                                                                                                     [100%]

============================================================ 2 passed in 4.52s =============================================================
Name                            Stmts   Miss Branch BrPart  Cover
-----------------------------------------------------------------
HSP2/ADCALC.py                    155    141     76      0    10%
HSP2/ATEMP.py                      27     19      4      0    32%
HSP2/CONS.py                      154    143     54      0     6%
HSP2/COPY.py                       18     10      2      0    40%
HSP2/GENER.py                     104     70     20      0    27%
HSP2/GQUAL.py                    1136   1116    454      0     2%
HSP2/HTRCH.py                     309    296    102      0     4%
HSP2/HYDR.py                      477    455    196      0     4%
HSP2/IQUAL.py                     182    173     58      0     5%
HSP2/IWATER.py                    199    166     72      3    17%
HSP2/IWTGAS.py                    116    104     36      0     9%
HSP2/NUTRX_Class.py               592    564    222      0     5%
HSP2/OXRX_Class.py                141    127     32      0     9%
HSP2/PHCARB_Class.py              130    117     32      0     9%
HSP2/PLANK_Class.py               960    914    334      1     5%
HSP2/PQUAL.py                     264    252     74      0     4%
HSP2/PSTEMP.py                    145    136     58      0     5%
HSP2/PWATER.py                    534    489    168      3     9%
HSP2/PWTGAS.py                    269    256     92      0     4%
HSP2/RQUAL.py                     349    330    182      0     4%
HSP2/RQUAL_Class.py               719    698    168      1     3%
HSP2/RQUTIL.py                     24     17     12      0    36%
HSP2/SEDMNT.py                    152    143     52      0     5%
HSP2/SEDTRN.py                    725    708    192      0     3%
HSP2/SNOW.py                      446    433    156      0     3%
HSP2/SOLIDS.py                     92     84     36      0     8%
HSP2/SPECL.py                       4      1      2      0    83%
HSP2/__init__.py                    4      0      0      0   100%
HSP2/configuration.py              41     13      0      0    68%
HSP2/main.py                      291    277    144      0     3%
HSP2/mainDoE.py                   194    175     90      0     7%
HSP2/state.py                     117     90     26      0    20%
HSP2/uci.py                        14     10      0      0    29%
HSP2/utilities.py                 318    256    224      5    14%
HSP2IO/io.py                       48     34     10      0    24%
HSP2IO/protocols.py                32      6     10      0    86%
_version.py                         1      0      0      0   100%
tests/__init__.py                   0      0      0      0   100%
tests/ipwater/__init__.py           0      0      0      0   100%
tests/ipwater/test_ipwater.py      46      0     16      0   100%
-----------------------------------------------------------------
TOTAL                            9529   8823   3406     13     7%

Here we see the tests pass, but line coverage can't be measured since it's all been compiled.

@austinorr
Copy link
Contributor Author

Request review from @PaulDudaRESPEC and @rburghol

Copy link
Member

@PaulDudaRESPEC PaulDudaRESPEC left a comment

Choose a reason for hiding this comment

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

Thanks for sharing all this @austinorr ! One request though, we've been trying to channel all the PRs into the develop branch instead of the main, so that we can move all the enhancements together into main at once when we're ready for a new release. I know you have a lot of expertise in this area... Is that OK with you as a standard operating procedure?

@austinorr
Copy link
Contributor Author

austinorr commented Apr 22, 2024

@PaulDudaRESPEC yep, that sounds fine. Is that the long-term branch management pattern that this project intends to use, or is this just temporary while we manage the current push of changes?

@austinorr austinorr changed the base branch from master to develop April 22, 2024 21:44
@austinorr
Copy link
Contributor Author

@PaulDudaRESPEC ok, rebased revisions on the develop branch.

Copy link
Member

@PaulDudaRESPEC PaulDudaRESPEC left a comment

Choose a reason for hiding this comment

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

Thanks @austinorr ! Yes, our intent was to direct all changes to the develop branch until ready for a new release -- I guess I should have mentioned it when we talked.

@PaulDudaRESPEC PaulDudaRESPEC merged commit a6abcfb into respec:develop Apr 23, 2024
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.

3 participants