Skip to content

Commit

Permalink
removing RunIndefinitely criterion (#331)
Browse files Browse the repository at this point in the history
Summary:
X-link: facebook/Ax#2156

Pull Request resolved: #331

Removing RunIndefinitely as its usecase is covered by setting num_trials = -1.

Reviewed By: mgarrard

Differential Revision: D53132233

fbshipit-source-id: fda48ec887cc5ba96c05612e21df16f230cfbfc1
  • Loading branch information
crasanders authored and facebook-github-bot committed Feb 9, 2024
1 parent 7d08769 commit 800b37f
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 23 deletions.
3 changes: 0 additions & 3 deletions aepsych/generators/completion_criterion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,18 @@
from .min_asks import MinAsks
from .min_total_outcome_occurrences import MinTotalOutcomeOccurrences
from .min_total_tells import MinTotalTells
from .run_indefinitely import RunIndefinitely

completion_criteria = [
MinTotalTells,
MinAsks,
MinTotalOutcomeOccurrences,
RunIndefinitely,
]

__all__ = [
"completion_criteria",
"MinTotalTells",
"MinAsks",
"MinTotalOutcomeOccurrences",
"RunIndefinitely",
]

Config.register_module(sys.modules[__name__])
1 change: 1 addition & 0 deletions aepsych/strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ def get_config_options(cls, config: Config, name: Optional[str] = None) -> Dict:
# Add an extra step at the end that we can `ask` endlessly.
final_step = copy(step)
final_step.completion_criteria = []
final_step.num_trials = -1
steps.append(final_step)

parameters = get_parameters(config)
Expand Down
20 changes: 0 additions & 20 deletions tests/generators/test_completion_criteria.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
MinAsks,
MinTotalOutcomeOccurrences,
MinTotalTells,
RunIndefinitely,
)
from aepsych.strategy import AEPsychStrategy

Expand Down Expand Up @@ -103,25 +102,6 @@ def test_min_total_outcome_occurences(self):
self.strat.complete_new_trial({"x": 1.0}, 1.0)
self.assertTrue(criterion.is_met(self.strat.experiment))

def run_indefinitely(self):
config_str = """
[common]
outcome_types = [binary]
run_indefinitely = False
"""
config = Config(config_str=config_str)
criterion = RunIndefinitely(**RunIndefinitely.from_config(config, "test_strat"))
self.assertTrue(criterion.is_met(self.strat.experiment))

config_str = """
[common]
outcome_types = [binary]
run_indefinitely = True
"""
config = Config(config_str=config_str)
criterion = RunIndefinitely(**RunIndefinitely.from_config(config, "test_strat"))
self.assertFalse(criterion.is_met(self.strat.experiment))


if __name__ == "__main__":
unittest.main()

0 comments on commit 800b37f

Please sign in to comment.