sandialabs / pyrocs

pyRoCS is a library of functions used to support resilience analysis of complex systems. The package contains example datasets and tutorial to help demonstrate how the functions can be used.
https://sandialabs.github.io/pyrocs/
Other
4 stars 1 forks source link

Test coverage improvements #9

Open kbonney opened 8 months ago

kbonney commented 8 months ago

Below is a coverage report for the test suite:

---------- coverage: platform linux, python 3.11.5-final-0 -----------
Name                                               Stmts   Miss  Cover   Missing
--------------------------------------------------------------------------------
pyrocs/__init__.py                                     1      0   100%
pyrocs/biosciences/__init__.py                         3      0   100%
pyrocs/biosciences/affinity.py                        35      2    94%   40, 77
pyrocs/biosciences/functional_redundancy.py            8      0   100%
pyrocs/biosciences/hill_diversity.py                  17      6    65%   99, 102-109
pyrocs/complex_systems/__init__.py                     3      0   100%
pyrocs/complex_systems/causal_complexity.py           31      2    94%   76-77
pyrocs/complex_systems/fluctuation_complexity.py      16     12    25%   32-46
pyrocs/complex_systems/grc.py                         10      3    70%   36, 39-40
pyrocs/information_theory/__init__.py                  4      0   100%
pyrocs/information_theory/entropy.py                  13      3    77%   46-48
pyrocs/information_theory/kl_divergence.py            34     18    47%   49-50, 98-123
pyrocs/information_theory/mutual_info.py               9      0   100%
pyrocs/version.py                                      6      0   100%
setup.py                                               2      2     0%   1-4
test/test_biosciences.py                              43      6    86%   79-84
test/test_complex_systems.py                          56      4    93%   123-126
test/test_information_theory.py                       25      4    84%   33-36
--------------------------------------------------------------------------------
TOTAL                                                316     62    80%

Looking into some of the missing lines reveals some major code blocks that aren't touched:

There are some other minor areas that aren't touched by the tests as listed in the "Missing" column, but these three look like the best spots for improvement.

ryanjcooper commented 3 months ago

New unit tests added, @kbonney can you rerun coverage?

kbonney commented 3 months ago

@ryanjcooper Below is the coverage run with the new tests. You can generate this by running coverage run --source=pyrocs -m pytest && coverage report --show-missing in the root of the repository. Looks like we have very strong coverage now!

Name                                               Stmts   Miss  Cover   Missing
--------------------------------------------------------------------------------
pyrocs/__init__.py                                     1      0   100%
pyrocs/biosciences/__init__.py                         3      0   100%
pyrocs/biosciences/affinity.py                        35      0   100%
pyrocs/biosciences/functional_redundancy.py            8      0   100%
pyrocs/biosciences/hill_diversity.py                  17      3    82%   106-109
pyrocs/complex_systems/__init__.py                     3      0   100%
pyrocs/complex_systems/causal_complexity.py           39      2    95%   85-86
pyrocs/complex_systems/fluctuation_complexity.py      16      0   100%
pyrocs/complex_systems/grc.py                         10      0   100%
pyrocs/information_theory/__init__.py                  4      0   100%
pyrocs/information_theory/entropy.py                  13      0   100%
pyrocs/information_theory/kl_divergence.py            34      0   100%
pyrocs/information_theory/mutual_info.py               9      0   100%
pyrocs/version.py                                      6      0   100%
--------------------------------------------------------------------------------
TOTAL                                                198      5    97%