Skip to content

Commit 433f0aa

Browse files
Copilottalgalili
andcommitted
Fix lint and formatting errors - add missing npt import
Co-authored-by: talgalili <976006+talgalili@users.noreply.github.com>
1 parent 52826de commit 433f0aa

7 files changed

Lines changed: 28 additions & 9 deletions

File tree

balance/stats_and_plots/weighted_comparisons_stats.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ def _weights_per_covars_names(covar_names: List[str]) -> pd.DataFrame:
121121

122122

123123
def _kl_divergence_discrete(
124-
p: npt.NDArray[np.floating[Any]], q: npt.NDArray[np.floating[Any]], eps: float = 1e-12
124+
p: npt.NDArray[np.floating[Any]],
125+
q: npt.NDArray[np.floating[Any]],
126+
eps: float = 1e-12,
125127
) -> float:
126128
"""
127129
Compute the KL divergence between two discrete probability mass functions.

balance/util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
)
3131

3232
import numpy as np
33+
import numpy.typing as npt
3334
import pandas as pd
3435

3536
import pandas.api.types as pd_types

tests/test_adjustment.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,9 @@ def test_apply_transformations_missing_column_specified(self) -> None:
417417
def test_apply_transformations_index_handling(self) -> None:
418418
"""Test that dataframe indices are properly handled during transformations."""
419419
source_df = pd.DataFrame({"d": [1, 2, 3]}, index=(5, 6, 7)) # pyre-ignore[6]
420-
target_df = pd.DataFrame({"d": [4, 5, 6, 7]}, index=(0, 1, 2, 3)) # pyre-ignore[6]
420+
target_df = pd.DataFrame(
421+
{"d": [4, 5, 6, 7]}, index=(0, 1, 2, 3)
422+
) # pyre-ignore[6]
421423
transformations = {"d": lambda x: x}
422424
result = apply_transformations((source_df, target_df), transformations)
423425
expected = (source_df, target_df)

tests/test_balancedf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,9 @@ def test_BalanceDFOutcomes_relative_response_rates(self) -> None:
253253
"""
254254
self.assertEqual(
255255
s_o.outcomes().relative_response_rates(),
256-
pd.DataFrame({"o1": [100.0, 4], "o2": [75.0, 3]}, index=["%", "n"]), # pyre-ignore[6]
256+
pd.DataFrame(
257+
{"o1": [100.0, 4], "o2": [75.0, 3]}, index=["%", "n"]
258+
), # pyre-ignore[6]
257259
lazy=True,
258260
)
259261

tests/test_cbps.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,9 @@ def test_cbps_consistency_with_default_arguments(self) -> None:
386386
# Create continuous variables for sample
387387
continuous_vars_sample = pd.concat(
388388
[
389-
pd.DataFrame(np.random.uniform(0, 10, size=SAMPLE_SIZE), columns=[0]), # pyre-ignore[6]
389+
pd.DataFrame(
390+
np.random.uniform(0, 10, size=SAMPLE_SIZE), columns=[0]
391+
), # pyre-ignore[6]
390392
pd.DataFrame(
391393
np.random.uniform(0, 1, size=(SAMPLE_SIZE, 4)), columns=range(1, 5)
392394
),

tests/test_rake.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,9 @@ def test_rake_consistency_with_default_arguments(self) -> None:
511511
# Create sample DataFrame with mixed data types
512512
sample_df = pd.concat(
513513
[
514-
pd.DataFrame(np.random.uniform(0, 10, size=n_sample), columns=[0]), # pyre-ignore[6]
514+
pd.DataFrame(
515+
np.random.uniform(0, 10, size=n_sample), columns=[0]
516+
), # pyre-ignore[6]
515517
pd.DataFrame(
516518
np.random.uniform(0, 1, size=(n_sample, 4)), columns=range(1, 5)
517519
),
@@ -529,7 +531,9 @@ def test_rake_consistency_with_default_arguments(self) -> None:
529531
# Create target DataFrame with mixed data types
530532
target_df = pd.concat(
531533
[
532-
pd.DataFrame(np.random.uniform(0, 18, size=n_target), columns=[0]), # pyre-ignore[6]
534+
pd.DataFrame(
535+
np.random.uniform(0, 18, size=n_target), columns=[0]
536+
), # pyre-ignore[6]
533537
pd.DataFrame(
534538
np.random.uniform(0, 1, size=(n_target, 4)), columns=range(1, 5)
535539
),

tests/test_util.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,9 @@ def test_drop_na_rows(self) -> None:
319319
sample_df,
320320
sample_weights,
321321
) = balance_util.drop_na_rows(sample_df, sample_weights, "sample")
322-
self.assertEqual(sample_df, pd.DataFrame({"a": (2.0), "b": ("c")}, index=[2])) # pyre-ignore[6]
322+
self.assertEqual(
323+
sample_df, pd.DataFrame({"a": (2.0), "b": ("c")}, index=[2])
324+
) # pyre-ignore[6]
323325
self.assertEqual(sample_weights, pd.Series([3], index=[2]))
324326

325327
# check exceptions
@@ -914,7 +916,9 @@ def test_quantize_preserves_column_order(self) -> None:
914916

915917
result = balance_util.quantize(df, q=4, variables=["first", "third"])
916918

917-
self.assertListEqual(list(result.columns), ["first", "second", "third"]) # pyre-ignore[16]
919+
self.assertListEqual(
920+
list(result.columns), ["first", "second", "third"]
921+
) # pyre-ignore[16]
918922
self.assertIsInstance(result.loc[0, "first"], pd.Interval) # pyre-ignore[16]
919923
self.assertEqual(result.loc[0, "second"], "a") # pyre-ignore[16]
920924
self.assertIsInstance(result.loc[0, "third"], pd.Interval) # pyre-ignore[16]
@@ -1582,7 +1586,9 @@ def test_fct_lump_by(self) -> None:
15821586
)
15831587

15841588
# test fct_lump_by doesn't affect indices when combining dataframes
1585-
s = pd.DataFrame({"d": [1, 1, 1], "e": ["a1", "a2", "a1"]}, index=(0, 6, 7)) # pyre-ignore[6]
1589+
s = pd.DataFrame(
1590+
{"d": [1, 1, 1], "e": ["a1", "a2", "a1"]}, index=(0, 6, 7)
1591+
) # pyre-ignore[6]
15861592
t = pd.DataFrame(
15871593
{"d": [2, 3, 1, 2], "e": ["a2", "a2", "a1", "a2"]}, index=(0, 1, 2, 3)
15881594
)

0 commit comments

Comments
 (0)