From e8cba96a200fdeb3c1fc7d6857cc38537ed0457b Mon Sep 17 00:00:00 2001 From: Lanqing Yuan Date: Sat, 16 Mar 2024 04:05:02 +0800 Subject: [PATCH] warning into init --- appletree/component.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/appletree/component.py b/appletree/component.py index c17d14b3..bf250928 100644 --- a/appletree/component.py +++ b/appletree/component.py @@ -53,6 +53,13 @@ def __init__(self, name: Optional[str] = None, llh_name: Optional[str] = None, * if "bins" in kwargs.keys() and "bins_type" in kwargs.keys(): self.set_binning(**kwargs) + if self.bins_type != "meshgrid" and self.add_eps_to_hist: + warn( + "It is empirically dangerous to have add_eps_to_hist==True,\ + when your bins_type is not meshgrid! It may lead to very bad fit with\ + lots of eff==0." + ) + def set_binning(self, **kwargs): """Set binning of component.""" if "bins" not in kwargs.keys() or "bins_type" not in kwargs.keys(): @@ -149,12 +156,6 @@ def implement_binning(self, mc, eff): raise ValueError(f"Unsupported bins_type {self.bins_type}!") if self.add_eps_to_hist: # as an uncertainty to prevent blowing up - if self.bins_type != "meshgrid": - warn( - "It is empirically dangerous to have add_eps_to_hist==True,\ - when your bins_type is not meshgrid! It may lead to very bad fit with\ - lots of eff==0." - ) hist = jnp.clip(hist, 1.0, jnp.inf) return hist