From ade69db7c23673fcbe9d2ac2b6dc348810b45bd0 Mon Sep 17 00:00:00 2001 From: karibbov Date: Tue, 18 Jun 2024 22:28:03 +0200 Subject: [PATCH] Fix AttributeError: 'int' object has no attribute 'nodes' --- .../bayesian_optimization/kernels/utils.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/neps/optimizers/bayesian_optimization/kernels/utils.py b/neps/optimizers/bayesian_optimization/kernels/utils.py index 1441f0f7..92ee1817 100644 --- a/neps/optimizers/bayesian_optimization/kernels/utils.py +++ b/neps/optimizers/bayesian_optimization/kernels/utils.py @@ -33,11 +33,16 @@ def extract_configs(configs: list[SearchSpace]) -> Tuple[list, list]: """ config_hps = [conf.get_normalized_hp_categories() for conf in configs] graphs = [hps["graphs"] for hps in config_hps] - - _nested_graphs = np.array(graphs, dtype=object) - if _nested_graphs.ndim == 3: - graphs = _nested_graphs[:, :, 0].reshape(-1).tolist() - + # Don't call np.array on structured objects + # https://github.com/numpy/numpy/issues/24546#issuecomment-1693913119 + # _nested_graphs = np.array(graphs, dtype=object) + # if _nested_graphs.ndim == 3 + # graphs = _nested_graphs[:, :, 0].reshape(-1).tolist() + # Long hand way of doing the above + if (len(graphs) > 0 and isinstance(graphs[0], list) + and len(graphs[0]) > 0 and isinstance(graphs[0][0], list)): + res = [_list for list_of_list in graphs for _list in list_of_list] + graphs = res return graphs, config_hps