Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug when bins_type is not set #153

Merged
merged 2 commits into from
Mar 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions appletree/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,21 @@ 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."
)
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():
raise ValueError("bins and bins_type must be set!")
self.bins = kwargs.get("bins")
self.bins_type = kwargs.get("bins_type")
if self.bins_type not in ["irreg", "meshgrid", None]:
raise ValueError(f"Unsupported bins_type {self.bins_type}!")

if self.bins_type == "meshgrid":
warning = "The usage of meshgrid binning is highly discouraged."
Expand Down Expand Up @@ -552,7 +554,7 @@ def new_component(self, llh_name: Optional[str] = None, pass_binning: bool = Tru
name=self.name + "_copy",
llh_name=llh_name,
bins=self.bins,
bins_type=self.bins,
bins_type=self.bins_type,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bug that we never captured.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for capturing this!

)
else:
raise ValueError("Should provide bins and bins_type if you want to pass binning!")
Expand Down
Loading