Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 13, 2025
1 parent 9b30418 commit 51207bc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
12 changes: 4 additions & 8 deletions acro/acro_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,13 +964,9 @@ def get_aggfunc(aggfunc: str | None) -> str | Callable | None:
func = None
if aggfunc is not None:
if not isinstance(aggfunc, str): # pragma: no cover
raise ValueError(
f"aggfunc {aggfunc} must be:" f"{', '.join(AGGFUNC.keys())}"
)
raise ValueError(f"aggfunc {aggfunc} must be:{', '.join(AGGFUNC.keys())}")
if aggfunc not in AGGFUNC: # pragma: no cover
raise ValueError(
f"aggfunc {aggfunc} must be: " f"{', '.join(AGGFUNC.keys())}"
)
raise ValueError(f"aggfunc {aggfunc} must be: {', '.join(AGGFUNC.keys())}")
func = AGGFUNC[aggfunc]
logger.debug("aggfunc: %s", func)
return func
Expand Down Expand Up @@ -1312,7 +1308,7 @@ def get_queries(masks, aggfunc) -> list[str]:
(
f"({index_level_names} == {row_label})"
if isinstance(row_label, (int, float))
else (f"({index_level_names}" f'== "{row_label}")')
else (f'({index_level_names}== "{row_label}")')
)
]
)
Expand All @@ -1333,7 +1329,7 @@ def get_queries(masks, aggfunc) -> list[str]:
(
f"({column_level_names} == {col_label})"
if isinstance(col_label, (int, float))
else (f"({column_level_names}" f'== "{col_label}")')
else (f'({column_level_names}== "{col_label}")')
)
]
)
Expand Down
4 changes: 1 addition & 3 deletions notebooks/test-nursery.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@
# Mean() in this case
# Then how Max and Min are not allowed by the code

print(
"\nIllustration of crosstab using an aggregation function " "- mean in this case."
)
print("\nIllustration of crosstab using an aggregation function - mean in this case.")
safe_table = acro.crosstab(df.recommend, df.parents, values=df.children, aggfunc="mean")
print("\nand this is the researchers output")
print(safe_table)
Expand Down
12 changes: 6 additions & 6 deletions test/test_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,9 @@ def test_surv_func(acro):
_ = acro.surv_func(data.futime, data.death, output="table")
output = acro.results.get_index(0)
correct_summary: str = "fail; threshold: 3864 cells suppressed; "
assert (
output.summary == correct_summary
), f"\n{output.summary}\n should be \n{correct_summary}\n"
assert output.summary == correct_summary, (
f"\n{output.summary}\n should be \n{correct_summary}\n"
)

filename = os.path.normpath("acro_artifacts/kaplan-meier_0.png")
_ = acro.surv_func(data.futime, data.death, output="plot")
Expand Down Expand Up @@ -876,9 +876,9 @@ def test_crosstab_multiple_aggregate_function(data, acro):
" p-ratio: 4 cells may need suppressing; "
"nk-rule: 2 cells may need suppressing; "
)
assert (
output.summary == correct_summary
), f"\n{output.summary}\n should be \n{correct_summary}\n"
assert output.summary == correct_summary, (
f"\n{output.summary}\n should be \n{correct_summary}\n"
)
print(f"{output.output[0]['mean']['R/G'].sum()}")
correctval = 97383496.0
errmsg = f"{output.output[0]['mean']['R/G'].sum()} should be {correctval}"
Expand Down
12 changes: 6 additions & 6 deletions test/test_stata17_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ def test_stata_acro_init():
options="",
stata_version="17",
)
assert (
ret == "acro analysis session created\n"
), f"wrong string for acro init: {ret}\n"
assert ret == "acro analysis session created\n", (
f"wrong string for acro init: {ret}\n"
)
errmsg = f"wrong type for stata_acro:{type(stata_config.stata_acro)}"
assert isinstance(stata_config.stata_acro, ACRO), errmsg

Expand Down Expand Up @@ -808,9 +808,9 @@ def test_table_stata17_2(data):
options="nototals",
stata_version="17",
)
assert (
ret.split() == ret_1.split() == correct.split()
), f"got\n{ret}\n expected\n{correct}"
assert ret.split() == ret_1.split() == correct.split(), (
f"got\n{ret}\n expected\n{correct}"
)


def test_table_stata17_3(data):
Expand Down
6 changes: 3 additions & 3 deletions test/test_stata_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ def test_stata_acro_init():
options="",
stata_version="16",
)
assert (
ret == "acro analysis session created\n"
), f"wrong string for acro init: {ret}\n"
assert ret == "acro analysis session created\n", (
f"wrong string for acro init: {ret}\n"
)
errmsg = f"wrong type for stata_acro:{type(stata_config.stata_acro)}"
assert isinstance(stata_config.stata_acro, ACRO), errmsg

Expand Down

0 comments on commit 51207bc

Please sign in to comment.