Skip to content

Commit

Permalink
codeflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jackaraz committed Jun 21, 2024
1 parent cc5ba4b commit 182f920
Showing 1 changed file with 14 additions and 46 deletions.
60 changes: 14 additions & 46 deletions src/spey/backends/default_pdf/simple_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,19 @@ def __init__(
self._main_kwargs = {}
"""Keyword arguments for main model"""

self._config = None
minimum_poi = -np.inf
if self.is_alive:
minimum_poi = -np.min(
self.background_yields[self.signal_yields > 0.0]
/ self.signal_yields[self.signal_yields > 0.0]
)

self._config = ModelConfig(
poi_index=0,
minimum_poi=minimum_poi,
suggested_init=[1.0],
suggested_bounds=[(minimum_poi, 10)],
)

@property
def is_alive(self) -> bool:
Expand Down Expand Up @@ -296,8 +308,6 @@ class Poisson(SimplePDFBase):
spey_requires: Text = SimplePDFBase.spey_requires
"""Spey version required for the backend"""

__slots__ = ["_model", "_main_model"]

def __init__(
self,
signal_yields: List[float],
Expand All @@ -308,20 +318,6 @@ def __init__(
signal_yields=signal_yields, background_yields=background_yields, data=data
)

minimum_poi = -np.inf
if self.is_alive:
minimum_poi = -np.min(
self.background_yields[self.signal_yields > 0.0]
/ self.signal_yields[self.signal_yields > 0.0]
)

self._config = ModelConfig(
poi_index=0,
minimum_poi=minimum_poi,
suggested_init=[1.0],
suggested_bounds=[(minimum_poi, 10)],
)


class Gaussian(SimplePDFBase):
r"""
Expand Down Expand Up @@ -362,23 +358,9 @@ def __init__(
signal_yields=signal_yields, background_yields=background_yields, data=data
)
self.absolute_uncertainties = np.array(absolute_uncertainties, dtype=np.float64)

minimum_poi = -np.inf
if self.is_alive:
minimum_poi = -np.min(
self.background_yields[self.signal_yields > 0.0]
/ self.signal_yields[self.signal_yields > 0.0]
)

"""absolute uncertainties on the background"""
self._main_kwargs = {"cov": self.absolute_uncertainties, "pdf_type": "gauss"}

self._config = ModelConfig(
poi_index=0,
minimum_poi=minimum_poi,
suggested_init=[1.0],
suggested_bounds=[(minimum_poi, 10)],
)


class MultivariateNormal(SimplePDFBase):
r"""
Expand Down Expand Up @@ -430,21 +412,7 @@ def __init__(
"Dimensionality of the covariance matrix should match to the background"
)

minimum_poi = -np.inf
if self.is_alive:
minimum_poi = -np.min(
self.background_yields[self.signal_yields > 0.0]
/ self.signal_yields[self.signal_yields > 0.0]
)

self._main_kwargs = {
"cov": self.covariance_matrix,
"pdf_type": "multivariategauss",
}

self._config = ModelConfig(
poi_index=0,
minimum_poi=minimum_poi,
suggested_init=[1.0],
suggested_bounds=[(minimum_poi, 10)],
)

0 comments on commit 182f920

Please sign in to comment.