fusion-energy / openmc-plasma-source

Creates a plasma source as an openmc.source object from input parameters that describe the plasma
MIT License
26 stars 11 forks source link

Testing TokamakSource generates points correctly #38

Closed LiamPattinson closed 2 years ago

LiamPattinson commented 2 years ago

I've added a test and refactored test_tokamak_source.py to ensure TokamakSource generates points within the expected shape. This change brings in hypothesis as an additional testing requirement, which is used to automatically generate a wide range of possible tokamaks and ensure it works for more than the single example given previously. It also includes a general refactor to avoid the repeated lines of code.

I believe this goes some way towards solving issue https://github.com/fusion-energy/openmc-plasma-source/issues/34, but I'd like to go a bit further. For example, the inputs to TokamakSource aren't checked for validity in its __init__ function. It would be quite straightforward to implement these checks and associated unit tests, and I could raise this as separate issue/pull request.

codecov[bot] commented 2 years ago

Codecov Report

Merging #38 (edbc0b2) into develop (ca46cab) will not change coverage. The diff coverage is 87.50%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop      #38   +/-   ##
========================================
  Coverage    96.34%   96.34%           
========================================
  Files            6        6           
  Lines          164      164           
========================================
  Hits           158      158           
  Misses           6        6           
Impacted Files Coverage Δ
openmc_plasma_source/plotting/__init__.py 100.00% <ø> (ø)
openmc_plasma_source/point_source.py 86.66% <80.00%> (ø)
openmc_plasma_source/ring_source.py 88.88% <80.00%> (ø)
openmc_plasma_source/tokamak_source.py 97.87% <90.00%> (ø)
...enmc_plasma_source/plotting/plot_tokamak_source.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1a09eb2...edbc0b2. Read the comment docs.

RemDelaporteMathurin commented 2 years ago

Sorry somehow I wasn't notified of this PR thanks @shimwell for pointing it out. I shall have a look asap!

shimwell commented 2 years ago

I am not sure why the pep workflow called black didn't run on this

LiamPattinson commented 2 years ago

Apologies for missing the PEP8 formatting, still trying to get in the habit of calling black regularly. Also not sure why it was missed by the CI.