]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
fix: narrow bare except to specific types in statistical helpers
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 1 May 2026 15:29:28 +0000 (17:29 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 1 May 2026 15:29:28 +0000 (17:29 +0200)
quickadapter/user_data/strategies/QuickAdapterV3.py

index 1efd1463b5614b53150a75a543c6fca352712e62..01a8d79111f811d78862aa3476147a5f3e2e92b0 100644 (file)
@@ -1912,7 +1912,8 @@ class QuickAdapterV3(IStrategy):
 
         try:
             rho1, _ = pearsonr(x_centered[:-1], x_centered[1:])
-        except Exception:
+        except (ValueError, TypeError) as exc:
+            logger.debug("[%s] pearsonr failed, using standard df: %r", "effective_df", exc)
             return n - 1
 
         if not np.isfinite(rho1):
@@ -1949,7 +1950,8 @@ class QuickAdapterV3(IStrategy):
             if not np.isfinite(t_crit):
                 return default_t
             return t_crit
-        except Exception:
+        except (ValueError, TypeError, OverflowError) as exc:
+            logger.debug("[%s] t.ppf failed, using default_t: %r", "t_critical", exc)
             return default_t
 
     def custom_exit(