From f47cb6da417819c0af2e84dba0590d90de9a98c7 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 27 Dec 2024 12:53:28 +0000 Subject: [PATCH] style: format code with Autopep8, isort and Ruff Formatter This commit fixes the style issues introduced in a1984fa according to the output from Autopep8, isort and Ruff Formatter. Details: None --- src/everyai/data_loader/dataprocess.py | 2 +- src/everyai/data_loader/everyai_dataset.py | 28 ++++++---------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/src/everyai/data_loader/dataprocess.py b/src/everyai/data_loader/dataprocess.py index bb901da..c761388 100644 --- a/src/everyai/data_loader/dataprocess.py +++ b/src/everyai/data_loader/dataprocess.py @@ -106,7 +106,7 @@ def split_remove_stopwords_punctuation(text: str, language="both") -> str: Defaults to 'both'. Returns: - str: Processed text with words split, punctuation removed, + str: Processed text with words split, punctuation removed, and stopwords removed. """ if language.lower() in ["zh", "chinese"]: diff --git a/src/everyai/data_loader/everyai_dataset.py b/src/everyai/data_loader/everyai_dataset.py index c194312..f8f0cbd 100644 --- a/src/everyai/data_loader/everyai_dataset.py +++ b/src/everyai/data_loader/everyai_dataset.py @@ -23,9 +23,7 @@ def __init__( if datas is not None: self.datas: pd.DataFrame = datas else: - self.datas: pd.DataFrame = pd.DataFrame( - columns=["question", "human"] - ) + self.datas: pd.DataFrame = pd.DataFrame(columns=["question", "human"]) if ai_list is not None: for ai_name in ai_list: self.datas[ai_name] = None @@ -59,17 +57,13 @@ def insert_ai_response(self, question, ai_name: str, ai_response: str): if question_exists: self._update_new_row(question, ai_name, ai_response) else: - self.datas.loc[self.datas["question"] == question, ai_name] = ( - ai_response - ) + self.datas.loc[self.datas["question"] == question, ai_name] = ai_response def insert_human_response(self, question, human_response: str): if self.datas[self.datas["question"] == question].empty: self._update_new_row(question, "human", human_response) else: - self.datas.loc[self.datas["question"] == question, "human"] = ( - human_response - ) + self.datas.loc[self.datas["question"] == question, "human"] = human_response # TODO Rename this here and in `insert_ai_response` and `insert_human_response` def _update_new_row(self, question, arg1, arg2): @@ -101,9 +95,7 @@ def _load_from_mongodb(self, database: pymongo.database.Database): data = data.drop(columns=["timestamp"]) self.datas = data - def load( - self, path_or_database: str | Path = None, formatter: str = "csv" - ): + def load(self, path_or_database: str | Path = None, formatter: str = "csv"): if formatter == "mongodb": if path_or_database is None: path_or_database = self._initialize_mongo_connection() @@ -124,9 +116,7 @@ def load( and path_or_database.suffix != f".{formatter}" ): logging.warning("Change file format to %s", formatter) - path_or_database = path_or_database.with_suffix( - f".{formatter}" - ) + path_or_database = path_or_database.with_suffix(f".{formatter}") else: logging.info("Loading dataset from %s", path_or_database) match formatter: @@ -143,9 +133,7 @@ def load( set(self.datas.columns) - {"question", "human", "timestamp"} ) - def save( - self, path_or_database: str | Path = None, formatter: str = "csv" - ): + def save(self, path_or_database: str | Path = None, formatter: str = "csv"): if formatter == "mongodb": if path_or_database is None: path_or_database = self._initialize_mongo_connection() @@ -164,9 +152,7 @@ def save( return if path_or_database.suffix != f".{formatter}": logging.warning("Change file format to %s", formatter) - path_or_database = path_or_database.with_suffix( - f".{formatter}" - ) + path_or_database = path_or_database.with_suffix(f".{formatter}") else: logging.info("Saving dataset to %s", path_or_database) match formatter: