From 46341b43c9bced853f27429db04977a19e2e39ce Mon Sep 17 00:00:00 2001 From: Nisha Grewal Date: Wed, 18 Nov 2026 10:16:22 +0000 Subject: [PATCH 1/3] Add logistic_function Poisson class --- src/onepower/utils/poisson.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/onepower/utils/poisson.py b/src/onepower/utils/poisson.py index 320bd0399..9db882126 100644 --- a/src/onepower/utils/poisson.py +++ b/src/onepower/utils/poisson.py @@ -61,4 +61,23 @@ def poisson_func(self): return poisson * (self.mass / (10.0**M_0)) ** slope +class logistic_function(Poisson): + """Logistic function mass dependent Poisson parameter.""" + + _defaults = {'poisson': 1.0, 'L': None, 'k': None, 'log10_M0': None} + + @property + def poisson_func(self): + poisson = self.params['poisson'] + L = self.params['L'] + k = self.params['k'] + log10_M0 = self.params['log10_M0'] + if L is None or k is None or log10_M0 is None: + raise ValueError( + "L, k, and log10_M0 must be provided for 'logistic_function' poisson type." + ) + return poisson * L / (1 + np.exp(-k * (np.log10(self.mass) - log10_M0))) + + + # Add more if needed! From c41521b561ba1f76eb83e8101d32de06b50345cb Mon Sep 17 00:00:00 2001 From: Nisha Grewal Date: Wed, 18 Nov 2026 10:20:07 +0000 Subject: [PATCH 2/3] Update Poisson docstring to include logistic function --- src/onepower/utils/poisson.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/onepower/utils/poisson.py b/src/onepower/utils/poisson.py index 9db882126..bdd387926 100644 --- a/src/onepower/utils/poisson.py +++ b/src/onepower/utils/poisson.py @@ -12,7 +12,8 @@ class Poisson(Component, metaclass=ABCMeta): """ Class to calculate the Poisson parameter for use in Pgg integrals. - Can be either a scalar (P = poisson) or a power law (P = poisson x (M/M_0)^slope), + Can be either a scalar (P = poisson), a power law (P = poisson x (M/M_0)^slope), + or a logistic function (P = poisson x L / (1 + exp(-k * (log10(M) - log10(M_0))))), by using the appropriate child class. Parent class is just an instance of an abstract class Further models can be added if necessary. From 93c3ad2a1fbd4045c5f6adc78ee342f761925537 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 18 Nov 2026 10:23:27 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- coverage.svg | 2 +- src/onepower/utils/poisson.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/coverage.svg b/coverage.svg index 79676920f..c3a0c4ccc 100644 --- a/coverage.svg +++ b/coverage.svg @@ -1 +1 @@ -coverage: 98.75%coverage98.75% \ No newline at end of file +coverage: 98.75%coverage98.75% diff --git a/src/onepower/utils/poisson.py b/src/onepower/utils/poisson.py index bdd387926..eadcd45db 100644 --- a/src/onepower/utils/poisson.py +++ b/src/onepower/utils/poisson.py @@ -12,7 +12,7 @@ class Poisson(Component, metaclass=ABCMeta): """ Class to calculate the Poisson parameter for use in Pgg integrals. - Can be either a scalar (P = poisson), a power law (P = poisson x (M/M_0)^slope), + Can be either a scalar (P = poisson), a power law (P = poisson x (M/M_0)^slope), or a logistic function (P = poisson x L / (1 + exp(-k * (log10(M) - log10(M_0))))), by using the appropriate child class. Parent class is just an instance of an abstract class Further models can be added if necessary. @@ -80,5 +80,4 @@ def poisson_func(self): return poisson * L / (1 + np.exp(-k * (np.log10(self.mass) - log10_M0))) - # Add more if needed!