From 62e43d4675deee8d18f098bb9c0a6704b0b1a886 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 17:18:55 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- acro/__init__.py | 1 + acro/acro_stata_parser.py | 7 ++++--- acro/acro_tables.py | 33 +++++++++++++++++++++------------ acro/stata_config.py | 1 + acro/version.py | 1 + notebooks/acro_demo_v2.ipynb | 6 +++--- notebooks/test-nursery.ipynb | 6 +++--- notebooks/test-nursery.py | 6 +++--- 8 files changed, 37 insertions(+), 24 deletions(-) diff --git a/acro/__init__.py b/acro/__init__.py index 2fb9651..b32ac21 100644 --- a/acro/__init__.py +++ b/acro/__init__.py @@ -1,3 +1,4 @@ """ACRO.""" + from .acro import * from .acro_regression import * diff --git a/acro/acro_stata_parser.py b/acro/acro_stata_parser.py index 5ed9b18..ed43334 100644 --- a/acro/acro_stata_parser.py +++ b/acro/acro_stata_parser.py @@ -3,6 +3,7 @@ Jim Smith 2023 @james.smith@uwe.ac.uk MIT licenses apply. """ + import pandas as pd import statsmodels.iolib.summary as sm_iolib_summary @@ -118,9 +119,9 @@ def parse_table_details(varlist: list, varnames: list, options: str) -> dict: extras = superrows.split() for word in extras: if word not in varnames: - details[ - "errmsg" - ] = f"Error: word {word} in by-list is not a variables name" + details["errmsg"] = ( + f"Error: word {word} in by-list is not a variables name" + ) return details if word not in details["rowvars"]: details["rowvars"].insert(0, word) diff --git a/acro/acro_tables.py b/acro/acro_tables.py index ddc72ea..0e9fca5 100644 --- a/acro/acro_tables.py +++ b/acro/acro_tables.py @@ -1,4 +1,5 @@ """ACRO: Tables functions.""" + # pylint: disable=too-many-lines from __future__ import annotations @@ -1237,35 +1238,43 @@ def get_queries(masks, aggfunc) -> list[str]: if isinstance(row_label, tuple): index_query = " & ".join( [ - f"({level} == {val})" - if isinstance(val, (int, float)) - else f'({level} == "{val}")' + ( + f"({level} == {val})" + if isinstance(val, (int, float)) + else f'({level} == "{val}")' + ) for level, val in zip(index_level_names, row_label) ] ) else: index_query = " & ".join( [ - f"({index_level_names} == {row_label})" - if isinstance(row_label, (int, float)) - else (f"({index_level_names}" f'== "{row_label}")') + ( + f"({index_level_names} == {row_label})" + if isinstance(row_label, (int, float)) + else (f"({index_level_names}" f'== "{row_label}")') + ) ] ) if isinstance(col_label, tuple): column_query = " & ".join( [ - f"({level} == {val})" - if isinstance(val, (int, float)) - else f'({level} == "{val}")' + ( + f"({level} == {val})" + if isinstance(val, (int, float)) + else f'({level} == "{val}")' + ) for level, val in zip(column_level_names, col_label) ] ) else: column_query = " & ".join( [ - f"({column_level_names} == {col_label})" - if isinstance(col_label, (int, float)) - else (f"({column_level_names}" f'== "{col_label}")') + ( + f"({column_level_names} == {col_label})" + if isinstance(col_label, (int, float)) + else (f"({column_level_names}" f'== "{col_label}")') + ) ] ) query = f"{index_query} & {column_query}" diff --git a/acro/stata_config.py b/acro/stata_config.py index 4f8791b..468307d 100644 --- a/acro/stata_config.py +++ b/acro/stata_config.py @@ -4,6 +4,7 @@ mutable hence use of lower case naming Jim Smith 2023. """ + import acro stata_acro = acro.ACRO() diff --git a/acro/version.py b/acro/version.py index 208a1fe..6c3e499 100644 --- a/acro/version.py +++ b/acro/version.py @@ -1,2 +1,3 @@ """ACRO version number.""" + __version__ = "0.4.5" diff --git a/notebooks/acro_demo_v2.ipynb b/notebooks/acro_demo_v2.ipynb index 426b844..ff217a0 100644 --- a/notebooks/acro_demo_v2.ipynb +++ b/notebooks/acro_demo_v2.ipynb @@ -392,9 +392,9 @@ "df[\"children\"] = pd.to_numeric(df[\"children\"])\n", "\n", "df[\"children\"] = df.apply(\n", - " lambda row: row[\"children\"]\n", - " if row[\"children\"] in (1, 2, 3)\n", - " else np.random.randint(4, 10),\n", + " lambda row: (\n", + " row[\"children\"] if row[\"children\"] in (1, 2, 3) else np.random.randint(4, 10)\n", + " ),\n", " axis=1,\n", ")" ] diff --git a/notebooks/test-nursery.ipynb b/notebooks/test-nursery.ipynb index 1ac8c32..c6734fe 100644 --- a/notebooks/test-nursery.ipynb +++ b/notebooks/test-nursery.ipynb @@ -309,9 +309,9 @@ "df[\"children\"] = pd.to_numeric(df[\"children\"])\n", "\n", "df[\"children\"] = df.apply(\n", - " lambda row: row[\"children\"]\n", - " if row[\"children\"] in (1, 2, 3)\n", - " else np.random.randint(4, 10),\n", + " lambda row: (\n", + " row[\"children\"] if row[\"children\"] in (1, 2, 3) else np.random.randint(4, 10)\n", + " ),\n", " axis=1,\n", ")" ] diff --git a/notebooks/test-nursery.py b/notebooks/test-nursery.py index 93bff39..bc29402 100644 --- a/notebooks/test-nursery.py +++ b/notebooks/test-nursery.py @@ -61,9 +61,9 @@ df["children"] = pd.to_numeric(df["children"]) df["children"] = df.apply( - lambda row: row["children"] - if row["children"] in (1, 2, 3) - else np.random.randint(4, 10), + lambda row: ( + row["children"] if row["children"] in (1, 2, 3) else np.random.randint(4, 10) + ), axis=1, )