From 6cc7ec416b65c3df8e63bcaa319cd9a0dd55015b Mon Sep 17 00:00:00 2001 From: Animaholic Date: Wed, 29 Mar 2023 07:44:35 -0400 Subject: [PATCH 1/3] added a try except block --- flaml/tune/searcher/flow2.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/flaml/tune/searcher/flow2.py b/flaml/tune/searcher/flow2.py index 035e3d8688..7c0f48472f 100644 --- a/flaml/tune/searcher/flow2.py +++ b/flaml/tune/searcher/flow2.py @@ -746,10 +746,13 @@ def reach(self, other: Searcher) -> bool: # unordered cat choice is hard to reach by chance if config1[key] != config2.get(key): return False - delta = np.array( - [ - incumbent1[key] - incumbent2.get(key, np.inf) - for key in self._tunable_keys - ] - ) + try: + delta = np.array( + [ + incumbent1[key] - incumbent2.get(key, np.inf) + for key in self._tunable_keys + ] + ) + except TypeError: + return False return np.linalg.norm(delta) <= self.step From c23019584ad42b17a57bda305a4b0060262c7d57 Mon Sep 17 00:00:00 2001 From: Animaholic Date: Mon, 3 Apr 2023 13:39:46 -0400 Subject: [PATCH 2/3] added a test --- test/automl/test_classification.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/automl/test_classification.py b/test/automl/test_classification.py index adb3081662..36d42a30d4 100644 --- a/test/automl/test_classification.py +++ b/test/automl/test_classification.py @@ -408,6 +408,14 @@ def test_sparse_matrix_lr(self): print(automl_experiment.best_iteration) print(automl_experiment.best_estimator) + def test_reach(self): + search_space = { + 'param_s': tune.choice([ + {'param': 'None'}, + {'param': tune.qrandint(10, 100, 10)} + ]), + } + return search_space if __name__ == "__main__": test = TestClassification() From 9bc17503c8de2b3f850529b34ef2fa044793e0aa Mon Sep 17 00:00:00 2001 From: Animaholic Date: Mon, 3 Apr 2023 14:13:59 -0400 Subject: [PATCH 3/3] small update --- test/automl/test_classification.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/automl/test_classification.py b/test/automl/test_classification.py index 36d42a30d4..aab0370861 100644 --- a/test/automl/test_classification.py +++ b/test/automl/test_classification.py @@ -410,13 +410,13 @@ def test_sparse_matrix_lr(self): def test_reach(self): search_space = { - 'param_s': tune.choice([ - {'param': 'None'}, - {'param': tune.qrandint(10, 100, 10)} - ]), + "params": tune.choice( + [{"param": "None"}, {"param": tune.qrandint(10, 100, 10)}] + ), } return search_space + if __name__ == "__main__": test = TestClassification() test.test_preprocess()