Skip to content

Commit e56c5f7

Browse files
committed
realized TVR wasn't finding best params for triangles in big experiment because order=1 was somehow still excluded. turns out to be a bug in the optimizer: default search space params are updated, and then the updated version is used everywhere, rather than starting fresh from the same defaults each time. Fixed with this commit.
1 parent 8a9bc1f commit e56c5f7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pynumdiff/optimize/_optimize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ def optimize(func, x, dt, dxdt_truth=None, tvgamma=1e-2, search_space_updates={}
195195
if metric not in ['rmse','error_correlation']:
196196
raise ValueError('`metric` should either be `rmse` or `error_correlation`.')
197197

198-
search_space, bounds = method_params_and_bounds[func]
199-
search_space.update(search_space_updates) # for things not given, use defaults
198+
default_search_space, bounds = method_params_and_bounds[func]
199+
search_space = {**default_search_space, **search_space_updates} # applies updates without mutating default
200200

201201
# No need to optimize over singletons, just pass them through
202202
singleton_params = {k:v for k,v in search_space.items() if not isinstance(v, (list, set))}

0 commit comments

Comments
 (0)