You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MNT Re-examine the check_is_fitted try/except pattern in _AdversarialFairness._validate_input #1657
try: # TODO check thischeck_is_fitted(self)
is_fitted=TrueexceptNotFittedError:
is_fitted=False
The try/except is used here to probe fit state — _validate_input legitimately needs to know whether the estimator has been fit yet so it can decide whether to call __setup and re-initialize.
Suggested action
Decide whether this probing pattern is appropriate and either remove the # TODO (with a brief justification) or refactor it. Options worth considering:
Replace with a direct attribute check on the fitted attribute (e.g. hasattr(self, "backendEngine_")), which avoids the round-trip through an exception path.
Keep the try/except but drop the stale # TODO and add a one-line explanation that we are intentionally probing the fit state.
Either resolution is small and self-contained.
Surfaced during a repo-cleanup audit by @romanlutz.
Re-examining check_is_fitted handling sounds worthwhile because broad try/except patterns can hide real estimator bugs. It may help to separate "estimator is not fitted" from "estimator validation raised for another reason" and only recover from the former. A regression test with a deliberately broken estimator that raises a different exception would make sure the validation path does not swallow actionable errors.
Activity
hiSandog commentedon Jun 29, 2026
Re-examining
check_is_fittedhandling sounds worthwhile because broad try/except patterns can hide real estimator bugs. It may help to separate "estimator is not fitted" from "estimator validation raised for another reason" and only recover from the former. A regression test with a deliberately broken estimator that raises a different exception would make sure the validation path does not swallow actionable errors.