Skip to content

Commit 39fe706

Browse files
generatedunixname89002005307016meta-codesync[bot]
authored andcommitted
Remove unused type error suppressions - core_stats
Summary: This diff was automatically generated by the Pyre per-target upgrade tool. It removes `# pyre-fixme` or `pyrefly: ignore` comments that are no longer needed because the underlying type errors have been resolved. Note that it will also aim to ensure type checking runs cleanly, and will add suppressions to existing type errors. #pyreupgrade Differential Revision: D116539709 fbshipit-source-id: f4a73ebea111fcd71e828cff67bdeac505af979b
1 parent a5681f8 commit 39fe706

24 files changed

Lines changed: 17 additions & 123 deletions

balance/balance_frame.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,8 @@ class BalanceFrame:
145145
False
146146
"""
147147

148-
# pyre-fixme[13]: Attributes are initialized in _create() / from_frame()
149148
_sf_sample_pre_adjust: SampleFrame
150-
# pyre-fixme[13]: Attributes are initialized in _create() / from_frame()
151149
_sf_sample: SampleFrame
152-
# pyre-fixme[13]: Attributes are initialized in _create() / from_frame()
153150
_sf_target: SampleFrame | None
154151
# pyre-fixme[13]: Attributes are initialized in _create() / from_frame()
155152
_adjustment_model: dict[str, Any] | None
@@ -171,21 +168,13 @@ def _sync_sampleframe_state_from_responder(self, responder: SampleFrame) -> None
171168
properties stay consistent with ``_sf_sample``.
172169
"""
173170
if isinstance(self, SampleFrame):
174-
# pyrefly: ignore [missing-attribute]
175171
self._df = responder._df
176-
# pyrefly: ignore [missing-attribute]
177172
self._id_column_name = responder._id_column_name
178-
# pyrefly: ignore [missing-attribute]
179173
self._column_roles = responder._column_roles
180-
# pyrefly: ignore [missing-attribute]
181174
self._weight_column_name = responder._weight_column_name
182-
# pyrefly: ignore [missing-attribute]
183175
self._weight_metadata = responder._weight_metadata
184-
# pyrefly: ignore [missing-attribute]
185176
self._prediction_metadata = responder._prediction_metadata
186-
# pyrefly: ignore [missing-attribute]
187177
self._outcome_model = responder._outcome_model
188-
# pyrefly: ignore [missing-attribute]
189178
self._df_dtypes = responder._df_dtypes
190179

191180
@staticmethod
@@ -256,7 +245,6 @@ def _df_dtypes(self) -> pd.Series | None:
256245

257246
@_df_dtypes.setter
258247
def _df_dtypes(self, value: pd.Series | None) -> None:
259-
# pyrefly: ignore [missing-attribute]
260248
self._sf_sample._df_dtypes = value
261249

262250
@property
@@ -295,7 +283,6 @@ def _df(self, value: pd.DataFrame | None) -> None:
295283
"Cannot set _df to None. A BalanceFrame must always have a "
296284
"backing DataFrame."
297285
)
298-
# pyrefly: ignore [missing-attribute]
299286
self._sf_sample._df = value
300287

301288
@property
@@ -475,7 +462,6 @@ def _create(
475462
instance._adjustment_history = []
476463
instance._links = collections.defaultdict(list)
477464
if target is not None:
478-
# pyrefly: ignore [unsupported-operation]
479465
instance._links["target"] = target
480466

481467
# When the instance is also a SampleFrame (e.g., Sample inherits
@@ -1718,7 +1704,6 @@ def _predict_outcomes_on_target(self, *, populate: bool) -> pd.DataFrame:
17181704
self._sf_target = target_copy
17191705
# Keep the raw-SampleFrame target link in sync with the populated copy
17201706
# (a richer BalanceFrame/Sample link is left untouched).
1721-
# pyrefly: ignore [not-iterable]
17221707
target_link = self._links.get("target") if self._links else None
17231708
if target_link is not None and not isinstance(target_link, BalanceFrame):
17241709
# pyrefly: ignore [unsupported-operation]
@@ -4186,7 +4171,6 @@ def _filter_sf(
41864171
df = df.loc[:, df.columns.isin(keep_set)]
41874172

41884173
new_covars = [c for c in sf._column_roles["covars"] if c in keep_set]
4189-
# pyrefly: ignore [missing-attribute]
41904174
sf._column_roles = dict(sf._column_roles)
41914175
sf._column_roles["covars"] = new_covars
41924176
if sf._column_roles["outcomes"]:
@@ -4202,7 +4186,6 @@ def _filter_sf(
42024186
c for c in sf._column_roles["ignored"] if c in keep_set
42034187
]
42044188

4205-
# pyrefly: ignore [missing-attribute]
42064189
sf._df = df
42074190
return sf
42084191

@@ -4523,7 +4506,6 @@ def __str__(self, pkg_source: str | None = None) -> str:
45234506

45244507
if self.has_target():
45254508
common_variables = balance_util.choose_variables(
4526-
# pyrefly: ignore [unsupported-operation]
45274509
self,
45284510
# pyrefly: ignore [unsupported-operation]
45294511
self._links["target"],

balance/cli.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,11 +1431,9 @@ def main(self) -> None:
14311431

14321432
logger.info("Done fitting the model, writing output")
14331433
# Remove unneeded rows and columns
1434-
# pyrefly: ignore [bad-argument-type]
14351434
output_df = self.adapt_output(output_df)
14361435

14371436
# Write output
1438-
# pyrefly: ignore [bad-argument-type]
14391437
self.write_outputs(output_df, diagnostics_df)
14401438

14411439

balance/datasets/loading_data.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def _create_outcome_happiness(df: pd.DataFrame, n: int) -> npt.NDArray[np.floati
6464
return out
6565

6666
if version == "01":
67-
# pyrefly: ignore [bad-argument-type]
6867
np.random.seed(2022 - 11 - 8) # for reproducibility
6968
n_target = 10000
7069
target_df = pd.DataFrame(
@@ -86,7 +85,6 @@ def _create_outcome_happiness(df: pd.DataFrame, n: int) -> npt.NDArray[np.floati
8685
# We also have missing values in gender
8786
target_df.loc[3:900, "gender"] = np.nan
8887

89-
# pyrefly: ignore [bad-argument-type]
9088
np.random.seed(2023 - 5 - 14) # for reproducibility
9189
n_sample = 1000
9290
sample_df = pd.DataFrame(

balance/stats_and_plots/impact_of_weights_on_outcome.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ def weights_impact_on_outcome_ss(
159159
ci_lower, ci_upper = mean_diff, mean_diff
160160
else:
161161
t_stat, p_value = stats.ttest_rel(yw1, yw0, nan_policy="omit")
162-
# pyrefly: ignore [missing-attribute]
163162
t_crit = stats.t.ppf((1 + conf_level) / 2, df=n_obs - 1)
164163
margin = t_crit * diff_std / np.sqrt(n_obs)
165164
ci_lower, ci_upper = mean_diff - margin, mean_diff + margin

balance/stats_and_plots/weighted_stats.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
from balance.stats_and_plots.weights_stats import _check_weights_are_valid
1717
from balance.util import model_matrix, rm_mutual_nas
1818
from balance.utils.input_validation import _assert_type
19-
20-
# pyrefly: ignore [missing-module-attribute]
2119
from scipy.stats import norm
2220
from statsmodels.stats.weightstats import DescrStatsW
2321

balance/weighting_methods/cbps.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,6 @@ def cbps( # noqa
533533
"""
534534

535535
logger.info("Starting cbps function")
536-
# pyrefly: ignore [bad-argument-type]
537536
np.random.seed(random_seed) # setting random seed for cases of variations in glmnet
538537

539538
balance_util._check_weighting_methods_input(sample_df, sample_weights, "sample")

balance/weighting_methods/ipw.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,6 @@ def ipw(
734734

735735
logger.info("Starting ipw function")
736736
np.random.seed(
737-
# pyrefly: ignore [bad-argument-type]
738737
random_seed
739738
) # setting random seed for cases of variations in sklearn
740739

tests/test_adjustment.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ def test_trim_weights(self) -> None:
7272
self.assertEqual(result_weights.dtype, np.float64)
7373

7474
# Test that no trimming parameters preserves original weights
75-
# pyrefly: ignore [bad-argument-type]
7675
np.random.seed(42)
7776
random_weights = np.random.uniform(0, 1, 10000)
7877
untrimmed_result = trim_weights(
@@ -103,7 +102,6 @@ def test_trim_weights(self) -> None:
103102
trim_weights(np.array([0, 1, 2]), 1, 1)
104103

105104
# Test weight_trimming_mean_ratio functionality
106-
# pyrefly: ignore [bad-argument-type]
107105
np.random.seed(42)
108106
original_weights = np.random.uniform(0, 1, 10000)
109107
mean_ratio_result = trim_weights(original_weights, weight_trimming_mean_ratio=1)
@@ -119,7 +117,6 @@ def test_trim_weights(self) -> None:
119117
)
120118

121119
# Test weight_trimming_percentile functionality
122-
# pyrefly: ignore [bad-argument-type]
123120
np.random.seed(42)
124121
test_weights = np.random.uniform(0, 1, 10000)
125122

tests/test_ascii_plots.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,6 @@ def test_blog_v0_20_0_comparative_hist_population_adjusted_sample(
844844
blog post (``website/blog/2026/04/26/balance-0-20-0.md``)."""
845845
from balance.sample_class import Sample
846846

847-
# pyrefly: ignore [bad-argument-type]
848847
np.random.seed(0)
849848
sample_df = pd.DataFrame(
850849
{

tests/test_balance_frame.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,7 +3566,7 @@ def test_build_adjusted_frame_migrates_legacy_ipw_fit_weight_aliases(self) -> No
35663566
self.assertNotIn("fit_sample_weights", cleaned_model)
35673567
self.assertNotIn("fit_target_weights", cleaned_model)
35683568

3569-
@pytest.mark.requires_sklearn_1_4 # pyre-ignore[56]
3569+
@pytest.mark.requires_sklearn_1_4
35703570
@unittest.skipUnless(_SKLEARN_1_4_AVAILABLE, "requires scikit-learn >= 1.4")
35713571
def test_store_fit_matrices_use_model_matrix_false(self) -> None:
35723572
from sklearn.ensemble import HistGradientBoostingClassifier
@@ -5246,7 +5246,7 @@ def test_predict_weights_cbps_zero_sum_weights_raises(self) -> None:
52465246
with self.assertRaisesRegex(ValueError, "positive sample and target weight"):
52475247
fitted.predict_weights(data=holdout_bf)
52485248

5249-
@pytest.mark.requires_sklearn_1_4 # pyre-ignore[56]
5249+
@pytest.mark.requires_sklearn_1_4
52505250
@unittest.skipUnless(_SKLEARN_1_4_AVAILABLE, "requires scikit-learn >= 1.4")
52515251
def test_blog_v0_20_0_fit_and_predict_weights_on_holdout(self) -> None:
52525252
"""Mirrors the "Reusable fit/predict workflows" snippet from the
@@ -5319,7 +5319,7 @@ def test_blog_v0_20_0_fit_and_predict_weights_on_holdout(self) -> None:
53195319
self.assertEqual(fitted_weights, [1.689, 1.127, 1.479, 1.083, 1.539, 1.083])
53205320
self.assertEqual(holdout_weights, [2.709, 2.582, 2.709])
53215321

5322-
@pytest.mark.requires_sklearn_1_4 # pyre-ignore[56]
5322+
@pytest.mark.requires_sklearn_1_4
53235323
@unittest.skipUnless(_SKLEARN_1_4_AVAILABLE, "requires scikit-learn >= 1.4")
53245324
def test_blog_v0_20_0_set_fitted_model_holdout_summary(self) -> None:
53255325
"""Mirrors the ``bf_holdout.set_fitted_model(fitted)`` +
@@ -5409,7 +5409,7 @@ def test_blog_v0_20_0_set_fitted_model_holdout_summary(self) -> None:
54095409
self.assertEqual(actual_lines, expected_lines)
54105410

54115411

5412-
@pytest.mark.requires_sklearn_1_4 # pyre-ignore[56]
5412+
@pytest.mark.requires_sklearn_1_4
54135413
@unittest.skipUnless(_SKLEARN_1_4_AVAILABLE, "requires scikit-learn >= 1.4")
54145414
class TestBlogV0_20_0SimDataHoldout(BalanceTestCase):
54155415
"""End-to-end tests for the v0.20.0 blog snippets that share a single
@@ -5538,7 +5538,6 @@ def test_blog_v0_20_0_simdata_holdout_outcomes_summary(self) -> None:
55385538
def test_blog_v0_20_0_simdata_holdout_r_indicator(self) -> None:
55395539
"""Mirrors ``bf_holdout.weights().r_indicator()`` from the
55405540
"r_indicator for representativeness" section."""
5541-
# pyrefly: ignore [missing-attribute]
55425541
value = float(self.bf_holdout.weights().r_indicator())
55435542
self.assertAlmostEqual(value, 0.5094452588289895, places=10)
55445543

@@ -5624,7 +5623,6 @@ def test_blog_v0_20_0_simdata_holdout_ascii_plot_full_output(self) -> None:
56245623
def test_blog_v0_20_0_simdata_holdout_covars_kld(self) -> None:
56255624
"""Mirrors ``bf_holdout.covars().kld()`` from the "Distribution
56265625
distances on raw categoricals" section."""
5627-
# pyrefly: ignore [missing-attribute]
56285626
kld = self.bf_holdout.covars().kld().round(6)
56295627
self.assertEqual(list(kld.index), ["self", "unadjusted", "unadjusted - self"])
56305628
self.assertEqual(
@@ -7778,7 +7776,7 @@ def test_transfer_drops_stale_outcomes_hat_on_holdout(self) -> None:
77787776
# The scored copy's responder no longer carries the stale Ŷ.
77797777
self.assertEqual(scored._sf_sample.outcomes_hat_columns, [])
77807778

7781-
@pytest.mark.requires_sklearn_1_4 # pyre-ignore[56]
7779+
@pytest.mark.requires_sklearn_1_4
77827780
@unittest.skipUnless(_SKLEARN_1_4_AVAILABLE, "requires sklearn >= 1.4")
77837781
def test_transfer_native_categorical_auto_learner(self) -> None:
77847782
# On sklearn>=1.4 the default learner uses the native-categorical path;

0 commit comments

Comments
 (0)