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

Refactor tranquilo code #395

Merged
merged 11 commits into from
Nov 4, 2022
Merged

Refactor tranquilo code #395

merged 11 commits into from
Nov 4, 2022

Conversation

janosg
Copy link
Member

@janosg janosg commented Nov 1, 2022

  • Improve construction of test cases in test_tranquilo.py.
  • Make sure we have one function to calculate the necessary number of parameters/degrees of freedom for linear and quadratic models. Should be defined in models.py.
  • Remove unused arguments in the aggregator interface.
  • Tests for input processing functions in tranquilo.py.

@codecov
Copy link

codecov bot commented Nov 1, 2022

Codecov Report

Merging #395 (e00d302) into main (4b9019f) will increase coverage by 0.10%.
The diff coverage is 96.34%.

@@            Coverage Diff             @@
##             main     #395      +/-   ##
==========================================
+ Coverage   92.62%   92.73%   +0.10%     
==========================================
  Files         208      209       +1     
  Lines       16372    16484     +112     
==========================================
+ Hits        15165    15286     +121     
+ Misses       1207     1198       -9     
Impacted Files Coverage Δ
src/estimagic/optimization/tranquilo/fit_models.py 83.73% <57.14%> (+0.19%) ⬆️
.../estimagic/optimization/tranquilo/filter_points.py 80.24% <66.66%> (+0.24%) ⬆️
src/estimagic/optimization/tranquilo/models.py 96.15% <93.75%> (-3.85%) ⬇️
...timagic/optimization/tranquilo/aggregate_models.py 87.71% <100.00%> (ø)
src/estimagic/optimization/tranquilo/tranquilo.py 95.85% <100.00%> (+5.38%) ⬆️
...ts/optimization/tranquilo/test_aggregate_models.py 100.00% <100.00%> (ø)
tests/optimization/tranquilo/test_filter_points.py 100.00% <100.00%> (ø)
tests/optimization/tranquilo/test_models.py 100.00% <100.00%> (ø)
tests/optimization/tranquilo/test_tranquilo.py 100.00% <100.00%> (ø)
...ptimization/subsolvers/bounded_newton_quadratic.py 86.40% <0.00%> (ø)
... and 2 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@timmens
Copy link
Member

timmens commented Nov 2, 2022

  1. subsolvers/quadratic_subsolvers.py, subsolvers/bounded_newton_quadratic.py and models.py contain functions to evaluate models. However, they use different arguments. In subsolvers/linear_subsolvers.py a linear model is evaluated, but we cannot use the other functions straight aways since they assume that the input has at least the attribute square_terms.
  2. Function _polynomial_features in fit_models.py is very similar to _square_features in filter_points.py. We could think about if we can combine these two or call one from the other. I did not find a way to efficiently / cleanly combine these two functions. It seems that for now we should keep both of them.

@timmens
Copy link
Member

timmens commented Nov 2, 2022

We will tackle problems 1. and 2. in separate PRs.

@timmens timmens requested a review from segsell November 2, 2022 15:43
Copy link
Member

@segsell segsell left a comment

Choose a reason for hiding this comment

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

Very nice refactoring PR! The test modules look way cleaner now. And great job finding out that np.linalg.lstsq is more robust than np.linalg.sovle in powell_fitting. Thank you!!

@segsell
Copy link
Member

segsell commented Nov 4, 2022

The powell fitting benchmarks (scalar case) now look slightly worse switching from np.linalg.solve to np.linalg.lstsq. But this is hardly noticeable in the relevant case of 2 * n + 1 points.

@janosg janosg merged commit e0b5b6c into main Nov 4, 2022
@janosg janosg deleted the refactoring branch November 4, 2022 14:39
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