From f203ea63f5c23692b85063669f94c6761c934196 Mon Sep 17 00:00:00 2001 From: Mohit Aggarwal Date: Sat, 24 Aug 2024 10:23:08 -0500 Subject: [PATCH] remove attrdict (#118) cleanup --- mango/domain/domain_space.py | 3 +-- mango/domain/parameter_sampler.py | 2 -- mango/metatuner.py | 2 -- mango/optimizer/bayesian_learning.py | 10 +++++----- mango/scheduler.py | 1 - mango/tuner.py | 3 ++- poetry.lock | 19 ++----------------- pyproject.toml | 3 +-- 8 files changed, 11 insertions(+), 32 deletions(-) diff --git a/mango/domain/domain_space.py b/mango/domain/domain_space.py index d092e29..4707665 100644 --- a/mango/domain/domain_space.py +++ b/mango/domain/domain_space.py @@ -2,7 +2,6 @@ import math import numpy as np from collections.abc import Callable -import warnings from itertools import compress from functools import cached_property import warnings @@ -272,7 +271,7 @@ def classify_parameters(param_dict: dict) -> (set, set, set, set): try: # this check takes care of numpy ints as well all_int = all( - x == int(x) and type(x) != bool for x in param_dict[par] + x == int(x) and not isinstance(x, bool) for x in param_dict[par] ) except (ValueError, TypeError): all_int = False diff --git a/mango/domain/parameter_sampler.py b/mango/domain/parameter_sampler.py index b5bed6b..1297386 100644 --- a/mango/domain/parameter_sampler.py +++ b/mango/domain/parameter_sampler.py @@ -1,5 +1,3 @@ -from abc import ABCMeta, abstractmethod - import warnings import numpy as np diff --git a/mango/metatuner.py b/mango/metatuner.py index 78eb037..c0d22b9 100644 --- a/mango/metatuner.py +++ b/mango/metatuner.py @@ -12,8 +12,6 @@ from tqdm.auto import tqdm import random - -## setting warnings to ignore for now import warnings warnings.filterwarnings("ignore") diff --git a/mango/optimizer/bayesian_learning.py b/mango/optimizer/bayesian_learning.py index d6eb199..95e9482 100644 --- a/mango/optimizer/bayesian_learning.py +++ b/mango/optimizer/bayesian_learning.py @@ -111,7 +111,8 @@ def Get_Upper_Confidence_Bound(self, X): return Value """ - Returns the most optmal x along with mean value from the domain of x and making sure it is not a Duplicate (depending on closeness) + Returns the most optmal x along with mean value from the domain of x and + making sure it is not a Duplicate (depending on closeness) used in batch setting: As mean is also returned """ @@ -128,7 +129,7 @@ def remove_duplicates(self, X, X_Sample, mu, Value): # check if x_optimal is in X_Sample check_closeness = self.closeness(x_optimal, X_Sample) - if check_closeness == False: # No close element to x_optimal in X_Sample + if check_closeness is False: # No close element to x_optimal in X_Sample break # we will look for next optimal value to try @@ -159,7 +160,7 @@ def remove_duplicates_serial(self, X, X_Sample, Value): # check if x_optimal is in X_Sample check_closeness = self.closeness(x_optimal, X_Sample) - if check_closeness == False: # No close element to x_optimal in X_Sample + if check_closeness is False: # No close element to x_optimal in X_Sample break # we will look for next optimal value to try @@ -287,7 +288,7 @@ def remove_duplicates_MetaTuner(self, X, X_Sample, mu, Value, Value_ext): # check if x_optimal is in X_Sample check_closeness = self.closeness(x_optimal, X_Sample) - if check_closeness == False: # No close element to x_optimal in X_Sample + if check_closeness is False: # No close element to x_optimal in X_Sample break # we will look for next optimal value to try @@ -386,7 +387,6 @@ def get_next_batch_MetaTuner( try: self.surrogate.fit(X_temp, Y_temp) - except: print("*" * 100) print(X_temp) diff --git a/mango/scheduler.py b/mango/scheduler.py index 75125bb..8a31a9f 100644 --- a/mango/scheduler.py +++ b/mango/scheduler.py @@ -35,7 +35,6 @@ def wrapper(params_batch): def celery(n_jobs, timeout=None): - import celery from celery import exceptions def decorator(func): diff --git a/mango/tuner.py b/mango/tuner.py index 23b6b51..59a045f 100644 --- a/mango/tuner.py +++ b/mango/tuner.py @@ -246,7 +246,8 @@ def runBayesianOptimizer(self): if len(Y_next_list) == 0: # no values returned - # this is problematic if domain is small and same value is tried again in the next iteration as the optimizer would be stuck + # this is problematic if domain is small and same value is tried again + # in the next iteration as the optimizer would be stuck continue Y_next_batch = Y_next_list.reshape(len(Y_next_list), 1) diff --git a/poetry.lock b/poetry.lock index 3d4489c..3e5ea6a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -148,21 +148,6 @@ files = [ [package.dependencies] typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.11\""} -[[package]] -name = "attrdict" -version = "2.0.1" -description = "A dict with attribute-style access" -category = "main" -optional = false -python-versions = "*" -files = [ - {file = "attrdict-2.0.1-py2.py3-none-any.whl", hash = "sha256:9432e3498c74ff7e1b20b3d93b45d766b71cbffa90923496f82c4ae38b92be34"}, - {file = "attrdict-2.0.1.tar.gz", hash = "sha256:35c90698b55c683946091177177a9e9c0713a0860f0e049febd72649ccd77b70"}, -] - -[package.dependencies] -six = "*" - [[package]] name = "attrs" version = "24.2.0" @@ -2440,7 +2425,7 @@ test = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "importlib-metadata name = "six" version = "1.16.0" description = "Python 2 and 3 compatibility utilities" -category = "main" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" files = [ @@ -2744,4 +2729,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = ">=3.10" -content-hash = "ae9be6776aef1524dcba4dc6432525eebbc562836f1de2809269f8780f0ff893" +content-hash = "44c0871dd4e1c628ba181ead91ee085215ee1dfd7040da34e3756a11aca4b60b" diff --git a/pyproject.toml b/pyproject.toml index 536484e..30d6c71 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "arm-mango" -version = "1.5.0" +version = "1.5.1" description = "parallel bayesian optimization over complex search spaces" authors = ["Sandeep Singh Sandha ", "Mohit Aggarwal "] license = "Apache-2.0" @@ -20,7 +20,6 @@ numpy = ">=1.17.0" scipy = ">=1.4.1" scikit_learn = ">=0.21.3" tqdm = ">=4.36.1" -attrdict = ">=2.0.1" [tool.poetry.group.dev.dependencies] black = "^24.2.0"