Skip to content

Commit

Permalink
[Tune] Replace lambda default arguments (#46596)
Browse files Browse the repository at this point in the history
This PR fixes instances where lambda functions are used as default
arguments. Since default arguments are evaluated at function definition
time, mutable objects can have unintuitive behavior; additionally, they
prevent our documentation from rendering correctly. This PR is part of
#45129, but has been split up to minimize codeowner impact.

Signed-off-by: pdmurray <peynmurray@gmail.com>
  • Loading branch information
peytondmurray authored Jul 15, 2024
1 parent aeb92f2 commit d9b91ed
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions python/ray/tune/tests/test_trial_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1372,9 +1372,10 @@ def assertProduces(fn, values):
seen.add(fn()["v"])
self.assertEqual(seen, values)

def explore_fn(
config, mutations, resample_probability, custom_explore_fn=lambda x: x
):
def explore_fn(config, mutations, resample_probability, custom_explore_fn=None):
if custom_explore_fn is None:
custom_explore_fn = lambda x: x # noqa: E731

new_config, _ = _explore(
config,
mutations,
Expand Down

0 comments on commit d9b91ed

Please sign in to comment.