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

Testing TokamakSource generates points correctly #38

Merged
merged 8 commits into from
Jan 27, 2022

Conversation

LiamPattinson
Copy link
Contributor

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 #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
Copy link

codecov bot commented Jan 26, 2022

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
Copy link
Member

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

Copy link
Member

@RemDelaporteMathurin RemDelaporteMathurin left a comment

Choose a reason for hiding this comment

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

Hi @LiamPattinson thank you so much for this very nice refactore!

I just had a few questions and minor pep8 style to apply here and there.

Otherwise I'm very happy with this PR!

.circleci/config.yml Show resolved Hide resolved
tests/test_tokamak_source.py Outdated Show resolved Hide resolved
tests/test_tokamak_source.py Outdated Show resolved Hide resolved
tests/test_tokamak_source.py Show resolved Hide resolved
@shimwell
Copy link
Member

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

@LiamPattinson
Copy link
Contributor Author

LiamPattinson commented Jan 27, 2022

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.

@RemDelaporteMathurin RemDelaporteMathurin merged commit 55a301e into fusion-energy:develop Jan 27, 2022
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