From fcb72ec49c2228e27730130eb06e6741e8b2eceb Mon Sep 17 00:00:00 2001 From: Clarence Mah Date: Fri, 5 Apr 2024 22:15:26 +0000 Subject: [PATCH] more merge conflicts --- bento/_settings.py | 101 --------------------------------------------- bento/tools/_lp.py | 4 +- 2 files changed, 2 insertions(+), 103 deletions(-) delete mode 100644 bento/_settings.py diff --git a/bento/_settings.py b/bento/_settings.py deleted file mode 100644 index 3aee303..0000000 --- a/bento/_settings.py +++ /dev/null @@ -1,101 +0,0 @@ -import logging -from rich.logging import RichHandler - - -class Settings: - """ - Settings class for Bento. - - Parameters - ---------- - verbosity : int - Verbosity level for logging. Default is 0. See the logging module for more information (https://docs.python.org/3/howto/logging.html#logging-levels). - log : logging.Logger - Logger object for Bento. - """ - - def __init__(self, verbosity): - self._verbosity = verbosity - self._log = Logger(verbosity) - - @property - def verbosity(self): - return self._verbosity - - @verbosity.setter - def verbosity(self, value): - self._verbosity = value - self._log.setLevel(value) - - @property - def log(self): - return self._log - - -class Logger: - def __init__(self, verbosity): - - FORMAT = "%(message)s" - logging.basicConfig( - level=verbosity, format=FORMAT, datefmt="[%X]", handlers=[RichHandler(markup=True)] - ) - self._logger = logging.getLogger("rich") - - def debug(self, text): - self._logger.debug(text) - - def info(self, text): - self._logger.info(text) - - def warn(self, text): - self._logger.warning(text) - - - def start(self, text): - """ - Alias for self.info(). Start logging a method. - - Parameters - ---------- - text : str - Text to log. - """ - self.info(f"[bold]{text}[/]") - - - def step(self, text): - """ - Alias for self.info(). Step logging. - - Parameters - ---------- - text : str - Text to log. - """ - self._logger.info(text) - - - def end(self, text): - """ - End logging. - - Parameters - ---------- - text : str - Text to log. - """ - self._logger.info(f"[bold]{text}[/]") - - def setLevel(self, value): - """ - Set the verbosity level of the logger. - - Parameters - ---------- - value : int - Verbosity level for logging. - """ - self._logger.setLevel(value) - - -settings = Settings(verbosity="WARNING") diff --git a/bento/tools/_lp.py b/bento/tools/_lp.py index bd3b4ce..82af1ba 100644 --- a/bento/tools/_lp.py +++ b/bento/tools/_lp.py @@ -87,8 +87,8 @@ def lp( X_df = sdata.table.uns[feature_key][pattern_features] # Load trained model - model_path = os.path.join(os.path.split(bento.__file__)[0], "models", "rf_calib_20220514.pkl") - model = pickle.load(open(model_path, "rb")) + model_dir = "/".join(bento.__file__.split("/")[:-1]) + "/models" + model = pickle.load(open(f"{model_dir}/rf_calib_20220514.pkl", "rb")) # Compatibility with newer versions of scikit-learn for cls in model.calibrated_classifiers_: