Skip to content

Commit

Permalink
add test case to ensure single trial in TransformToNewSQ (#2897)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #2897

This tests that if there is only one trial with status quo data, that trial is not transformed.

Reviewed By: lena-kashtelyan

Differential Revision: D64486972

fbshipit-source-id: 0108993d2bc1a4842aeaec66d2bd6195957ea695
  • Loading branch information
sdaulton authored and facebook-github-bot committed Oct 16, 2024
1 parent dacedfc commit adf4763
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions ax/modelbridge/transforms/tests/test_transform_to_new_sq.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ def setUp(self) -> None:
with_batch=True,
with_status_quo=True,
)
for t in self.exp.trials.values():
t.mark_running(no_runner_required=True)
self.exp.attach_data(
get_branin_data_batch(batch=checked_cast(BatchTrial, t))
)
t.mark_completed()
t = self.exp.trials[0]
t.mark_running(no_runner_required=True)
self.exp.attach_data(get_branin_data_batch(batch=checked_cast(BatchTrial, t)))
t.mark_completed()
self.data = self.exp.fetch_data()

self.modelbridge = ModelBridge(
Expand Down Expand Up @@ -123,3 +121,15 @@ def test_custom_target_trial(self) -> None:
config={"target_trial_index": 1},
)
self.assertEqual(tf.default_trial_idx, 1)

def test_single_trial_is_not_transformed(self) -> None:
tf = TransformToNewSQ(
search_space=None,
observations=[],
modelbridge=self.modelbridge,
)
obs = self.modelbridge._prepare_observations(
experiment=self.exp, data=self.data
)
obs2 = tf.transform_observations(obs)
self.assertEqual(obs, obs2)

0 comments on commit adf4763

Please sign in to comment.