FormingWorlds / PROTEUS

Coupled atmosphere-interior framework to simulate the temporal evolution of rocky planets.
https://fwl-proteus.readthedocs.io
Apache License 2.0
12 stars 1 forks source link

PROTEUS unit tests #268

Open timlichtenberg opened 1 week ago

timlichtenberg commented 1 week ago

We should aim to get the test coverage to 100% before the PROTEUS method paper in JOSS. Alternatively we need to label (or remove) parts of the code that are not yet necessary anymore.

nichollsh commented 1 week ago

Here's a breakdown of the current test coverage, for reference.

Name                                         Stmts   Miss Branch BrPart  Cover
------------------------------------------------------------------------------
src/proteus/__init__.py                          4      0      0      0   100%
src/proteus/atmos_clim/__init__.py               3      0      0      0   100%
src/proteus/atmos_clim/agni.py                 199    199     48      0     0%
src/proteus/atmos_clim/common.py                49      2     12      2    93%
src/proteus/atmos_clim/dummy.py                 70     18     14      4    69%
src/proteus/atmos_clim/janus.py                137     29     44     12    72%
src/proteus/atmos_clim/wrapper.py               88     39     30      8    55%
src/proteus/cli.py                              82     82      8      0     0%
src/proteus/config/__init__.py                  13      0      0      0   100%
src/proteus/config/_atmos_clim.py               62      5      6      3    88%
src/proteus/config/_config.py                   33      0      0      0   100%
src/proteus/config/_converters.py               12      0      6      0   100%
src/proteus/config/_delivery.py                 28      0      0      0   100%
src/proteus/config/_escape.py                   17      0      0      0   100%
src/proteus/config/_interior.py                 28      0      0      0   100%
src/proteus/config/_orbit.py                    11      0      0      0   100%
src/proteus/config/_outgas.py                   24      0      0      0   100%
src/proteus/config/_params.py                   69      1      2      1    97%
src/proteus/config/_star.py                     21      0      0      0   100%
src/proteus/config/_struct.py                    9      0      0      0   100%
src/proteus/escape/wrapper.py                   48      3     20      3    91%
src/proteus/interior/__init__.py                 3      0      0      0   100%
src/proteus/interior/aragog.py                  86      1      8      1    98%
src/proteus/interior/dummy.py                   53      2     10      2    94%
src/proteus/interior/spider.py                 259    259     52      0     0%
src/proteus/interior/timestep.py                51      5     14      3    88%
src/proteus/interior/wrapper.py                 94     18     38      9    77%
src/proteus/orbit/__init__.py                    2      0      0      0   100%
src/proteus/orbit/wrapper.py                    11      0      0      0   100%
src/proteus/outgas/__init__.py                   3      0      0      0   100%
src/proteus/outgas/atmodeller.py                 6      6      2      0     0%
src/proteus/outgas/calliope.py                  52      7     22      5    84%
src/proteus/outgas/wrapper.py                   22      3     12      3    82%
src/proteus/plot/__init__.py                    22      0      0      0   100%
src/proteus/plot/_cpl_helpers.py                 7      0      0      0   100%
src/proteus/plot/cpl_atmosphere.py              51     10      8      3    78%
src/proteus/plot/cpl_atmosphere_cbar.py         72     55     14      2    22%
src/proteus/plot/cpl_elements.py                50      8     10      3    82%
src/proteus/plot/cpl_emission.py                86     21     16      5    71%
src/proteus/plot/cpl_escape.py                  51      9     12      5    78%
src/proteus/plot/cpl_fluxes_atmosphere.py       52      5      4      2    88%
src/proteus/plot/cpl_fluxes_global.py           55      9      6      3    80%
src/proteus/plot/cpl_global.py                 134     10     42      3    91%
src/proteus/plot/cpl_heatingrates.py            40     30      6      2    26%
src/proteus/plot/cpl_interior.py               137     35     46     13    64%
src/proteus/plot/cpl_interior_cmesh.py         124     28     44     12    71%
src/proteus/plot/cpl_observables.py             42      8      6      3    77%
src/proteus/plot/cpl_offchem_grid_cross.py     126    112     48      2     9%
src/proteus/plot/cpl_offchem_species.py         79     64     24      2    17%
src/proteus/plot/cpl_offchem_time.py            91     78     34      2    12%
src/proteus/plot/cpl_offchem_year.py            64     51     22      2    17%
src/proteus/plot/cpl_population.py             110     12     16      5    87%
src/proteus/plot/cpl_sflux.py                   96     23     28     10    73%
src/proteus/plot/cpl_sflux_cross.py             92     22     26      6    75%
src/proteus/plot/cpl_structure.py              109     19     18      5    80%
src/proteus/proteus.py                         231     57     66     12    75%
src/proteus/star/__init__.py                     2      0      0      0   100%
src/proteus/star/dummy.py                       30      0      6      2    94%
src/proteus/star/wrapper.py                    110     13     34      8    80%
src/proteus/utils/constants.py                  39      0      0      0   100%
src/proteus/utils/coupler.py                   275     23     82     19    88%
src/proteus/utils/data.py                      138     74     36      6    44%
src/proteus/utils/helper.py                    134     55     68     11    50%
src/proteus/utils/logs.py                       74     25     20      6    59%
src/proteus/utils/phys.py                       16      0      0      0   100%
src/proteus/utils/plot.py                      123     63     32      4    46%
src/proteus/utils/plot_offchem.py               85     76     32      0     8%
------------------------------------------------------------------------------
TOTAL                                         4596   1674   1154    214    60%
nichollsh commented 1 week ago

A lot of it is the offline chemistry stuff, which is going to be completely reworked anyway. Some of it is the AGNI wrapper, which we could address quite easily. Some of it is from the SPIDER wrapper, which would be harder to do.

timlichtenberg commented 1 week ago

Ok, I believe the offline chemistry lines will probably be touched anyway within the next few months I presume, so that seems doable. The SPIDER wrapper in itself is probably reasonable to touch, but I agree we shouldn't go overboard with this.

lsoucasse commented 1 week ago

I agree it is important to increase the coverage but I don't think the 100% coverage is a reasonable goal. It is not required for JOSS.

timlichtenberg commented 1 week ago

It is not required, but why is it in general unreasonable? I understand that this means rigorously sorting the current code lines. But in truth, any thing below 100% will in the long run become much harder to keep up because in practice it will be difficult to keep track of where tests are missing, when many users are adding code lines.

lsoucasse commented 1 week ago

What I mean is that 100% coverage is great but it requires a lot of effort and doesn't mean that it is bug-free because it depends on how to test things. The mors bug is a good example, everything works fine at low time evolution and then you add one data point at a bigger time (which does not increase the coverage) and then the test fails. Also at the moment we change the test data more or less at each PR because adding new physics/parameters change everything. We are happy because the test pass but it does not guarantee the implementation is correct. In conclusion, I definitely agree we need to increase the coverage but it should not be the unique focus point.