-
Notifications
You must be signed in to change notification settings - Fork 1
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
Refactor BaseModel #365
Refactor BaseModel #365
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #365 +/- ##
===========================================
- Coverage 93.50% 93.30% -0.20%
===========================================
Files 59 59
Lines 2954 2866 -88
===========================================
- Hits 2762 2674 -88
Misses 192 192 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a great idea XDDD
Jokes aside, the code now looks much cleaner and I feel it will be more robust. Great work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :-)
Description
This implements @dalonsoa's suggested refactor of
BaseModel
from #363. We thought this seemed like a good idea at the Github meeting so I've worked it through.Briefly, that changes how we set model class attributes from:
to
Another change that fell out of this update is that it looked much cleaner to have a single
model_update_bounds
attribute set like('1 day', '1 month')
rather than separating those aslower_bound_on_time_scale
andupper_bound_on_time_scale
. It means_check_time_bounds_units
is replaced by_check_model_update_bounds
, which is only called once and also moves the test that1 day < 1 month
inside the check function.Pros on the switch
__init__subclass__
runs.exec()
to run chunks of text that described model definitions in order to set different attributes for testing. We can now just pass those attributes in to tests askwargs
to the model creation call.Cons on the switch
PlantsModel.required_init_vars
that gave an overview. I've moved that into a specific section in the model docstring instead. (Honestly I'm not sure this is really a con - that seems like a more logical place for people to read about model requirements).Fixes #363 (issue)
Type of change
Key checklist
pre-commit
checks:$ pre-commit run -a
$ poetry run pytest
Further checks