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

Major refactoring of the parametric shapes and parametric components default parameters #354

Closed

Conversation

RemDelaporteMathurin
Copy link

@RemDelaporteMathurin RemDelaporteMathurin commented Oct 11, 2020

Proposed changes

@billingsley-john proposed in #115 a way of simplifying classes initialisation with a default dict.
However, since most of these parameters are already defaulted at the Shape level (which is inherited by all classes in paramak), this default_dict can be replaced by the kwargs.

This PR shows how to perform this refactoring and includes it for all the parametric shapes (eg, RotateStraightShape, ExtrudeSplineShape, etc.) and for the shapes inherited from Plasma (PlasmaFromPoints, PlasmaBoundaries).

In the future, this should be done for all components which would:

  • strongly reduce code repetition
  • increase readibility
  • simplify the docstrings

Types of changes

What types of changes does your code introduce to the Paramak?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code refactoring
  • Documentation Update (if none of the other choices apply)
  • New tests

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • Pep8 applied
  • Unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

@billingsley-john @shimwell what are your thoughts ?
this could be a nice "Good first issue".

@codecov
Copy link

codecov bot commented Oct 11, 2020

Codecov Report

Merging #354 into develop will increase coverage by 0.27%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #354      +/-   ##
===========================================
+ Coverage    95.78%   96.06%   +0.27%     
===========================================
  Files           49       49              
  Lines         2871     2820      -51     
===========================================
- Hits          2750     2709      -41     
+ Misses         121      111      -10     
Impacted Files Coverage Δ
paramak/parametric_components/tokamak_plasma.py 97.05% <ø> (-0.17%) ⬇️
...arametric_components/tokamak_plasma_from_points.py 100.00% <ø> (+7.14%) ⬆️
paramak/parametric_shapes/extruded_circle_shape.py 100.00% <ø> (+5.88%) ⬆️
paramak/parametric_shapes/extruded_mixed_shape.py 100.00% <ø> (ø)
paramak/parametric_shapes/extruded_spline_shape.py 100.00% <ø> (+7.14%) ⬆️
...ramak/parametric_shapes/extruded_straight_shape.py 100.00% <ø> (ø)
paramak/parametric_shapes/rotate_circle_shape.py 100.00% <ø> (+6.06%) ⬆️
paramak/parametric_shapes/rotate_mixed_shape.py 100.00% <ø> (ø)
paramak/parametric_shapes/rotate_spline_shape.py 100.00% <ø> (ø)
paramak/parametric_shapes/rotate_straight_shape.py 100.00% <ø> (ø)
... and 1 more

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 5c55c5b...388ab68. Read the comment docs.

@shimwell
Copy link
Collaborator

This is an epic improvement

@RemDelaporteMathurin
Copy link
Author

@shimwell I estimated an approximately 27% code reduction if this was made to all parametric components !
Coverage will also increase (:green_circle:) since these default dict lines are usually not hit by the test suite (see here)

A similar thing could be done to the reactor classes since they are some default parameters repetitions

@shimwell
Copy link
Collaborator

Thanks for this Remi, I'm going to take a look tomorrow. A bit of progress elsewhere today as I merged the new cutters and simple neutronics simulations are working

@shimwell
Copy link
Collaborator

This looks great, but I also wondering if we could do with a few more tests before implementing this. Many of the parametric shape tests just check the solid is not None and something has been constructed. Adding to my ToDo list

@RemDelaporteMathurin
Copy link
Author

This looks great, but I also wondering if we could do with a few more tests before implementing this. Many of the parametric shape tests just check the solid is not None and something has been constructed. Adding to my ToDo list

@shimwell we could surely do more testing yes. What kind of tests are you thinking of ?

@shimwell
Copy link
Collaborator

This looks great, but I also wondering if we could do with a few more tests before implementing this. Many of the parametric shape tests just check the solid is not None and something has been constructed. Adding to my ToDo list

@shimwell we could surely do more testing yes. What kind of tests are you thinking of ?

I'm thinking some more tests that check the arguments, including kwargs impact the shape construction.

@RemDelaporteMathurin
Copy link
Author

@shimwell we could surely do more testing yes. What kind of tests are you thinking of ?

I'm thinking some more tests that check the arguments, including kwargs impact the shape construction.

Like sanity tests that check the arguments we set in kwargs are kept after construction ?

@RemDelaporteMathurin
Copy link
Author

Closing this. Extended in #357

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.

None yet

2 participants