Skip to content

Commit

Permalink
Use default dtype in Experiment.clone_with
Browse files Browse the repository at this point in the history
Summary: Replaces `Data.from_multiple_data` with `self.default_data_constructor.from_multiple_data`, which will use `MapData.from_multiple_data` where applicable.

Reviewed By: Balandat

Differential Revision: D51333709

fbshipit-source-id: c4925bd0a5d5bcb513eed71a7c22ea10078e3ef7
  • Loading branch information
saitcakmak authored and facebook-github-bot committed Nov 20, 2023
1 parent 2916d0d commit 375bf47
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ax/core/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -1587,7 +1587,9 @@ def clone_with(
else:
raise NotImplementedError(f"Cloning of {type(trial)} is not supported.")

cloned_experiment.attach_data(Data.from_multiple_data(datas))
cloned_experiment.attach_data(
self.default_data_constructor.from_multiple_data(datas)
)

return cloned_experiment

Expand Down
12 changes: 12 additions & 0 deletions ax/core/tests/test_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
get_search_space,
get_sobol,
get_status_quo,
get_test_map_data_experiment,
)

DUMMY_RUN_METADATA_KEY = "test_run_metadata_key"
Expand Down Expand Up @@ -1054,6 +1055,17 @@ def test_clone_with(self) -> None:
checked_cast(Arm, experiment.status_quo).parameters, {"x1": 0.0, "x2": 0.0}
)

# Clone with MapData.
experiment = get_test_map_data_experiment(
num_trials=5, num_fetches=3, num_complete=4
)
cloned_experiment = experiment.clone_with(
search_space=larger_search_space,
status_quo=new_status_quo,
)
new_data = cloned_experiment.lookup_data()
self.assertIsInstance(new_data, MapData)


class ExperimentWithMapDataTest(TestCase):
def setUp(self) -> None:
Expand Down

0 comments on commit 375bf47

Please sign in to comment.