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

Reduce memory footprint #884

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions backtesting/backtesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ def _optimize_skopt() -> Union[pd.Series,
# Avoid recomputing re-evaluations:
# "The objective has been evaluated at this point before."
# https://github.com/scikit-optimize/scikit-optimize/issues/302
memoized_run = lru_cache()(lambda tup: self.run(**dict(tup)))
memoized_run = lru_cache()(lambda tup: -maximize(self.run(**dict(tup))))

# np.inf/np.nan breaks sklearn, np.finfo(float).max breaks skopt.plots.plot_objective
INVALID = 1e300
Expand All @@ -1494,8 +1494,7 @@ def objective_function(**params):
# TODO: Adjust after https://github.com/scikit-optimize/scikit-optimize/pull/971
if not constraint(AttrDict(params)):
return INVALID
res = memoized_run(tuple(params.items()))
value = -maximize(res)
value = memoized_run(tuple(params.items()))
if np.isnan(value):
return INVALID
return value
Expand Down