Skip to content

Commit

Permalink
Merge pull request #510 from PyFstat/508-fix-ipg-examples
Browse files Browse the repository at this point in the history
isotropic_amplitude_priors is not global anymore
  • Loading branch information
dbkeitel authored Dec 1, 2022
2 parents 5239a9a + b8252e4 commit 1458a1f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
AllSkyInjectionParametersGenerator,
InjectionParametersGenerator,
Writer,
isotropic_amplitude_priors,
isotropic_amplitude_distribution,
set_up_logger,
)

Expand Down Expand Up @@ -53,7 +53,7 @@
amplitude_params_generator = InjectionParametersGenerator(
priors={
"h0": {"stats.norm": {"loc": 1e-24, "scale": 1e-26}},
**isotropic_amplitude_priors,
**isotropic_amplitude_distribution,
},
seed=42,
)
Expand Down
4 changes: 2 additions & 2 deletions examples/tutorials/1_generating_signals.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@
"from generic distributions in a suitable format, ready to be fed into `pyfstat.Writer`.\n",
"Uniform sampling across the sky is baked in the child class `pyfstat.AllSkyInjectionParametersGenerator`,\n",
"and isotropic priors on amplitude parameters are available in \n",
"`pyfstat.injection_parameters.isotropic_amplitude_priors`.\n",
"`pyfstat.isotropic_amplitude_distribution`.\n",
"\n",
"All-sky searches tend to perform injection campaigns at fixed values of `h0` (or, equivalently, $\\mathcal{D}$)."
]
Expand Down Expand Up @@ -327,7 +327,7 @@
" \"F1\": -1e-10,\n",
" \"F2\": 0,\n",
" \"h0\": writer_kwargs[\"sqrtSX\"] / 10, # Fix amplitude at depth 10.\n",
" **pyfstat.injection_parameters.isotropic_amplitude_priors,\n",
" **pyfstat.isotropic_amplitude_distribution,\n",
" \"tref\": writer_kwargs[\"tstart\"],\n",
" },\n",
")\n",
Expand Down
1 change: 1 addition & 0 deletions pyfstat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from .injection_parameters import (
AllSkyInjectionParametersGenerator,
InjectionParametersGenerator,
isotropic_amplitude_distribution,
)
from .make_sfts import (
BinaryModulatedWriter,
Expand Down
25 changes: 24 additions & 1 deletion pyfstat/injection_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def negative_log_uniform(generator, size):
We are following here R. Prix: https://dcc.ligo.org/T0900149-v6/public
"""
isotropic_amplitude_priors = {
isotropic_amplitude_distribution = {
"cosi": {"stats.uniform": {"loc": -1.0, "scale": 2.0}},
"psi": {"stats.uniform": {"loc": -0.25 * np.pi, "scale": 0.5 * np.pi}},
"phi": {"stats.uniform": {"loc": 0, "scale": 2 * np.pi}},
Expand Down Expand Up @@ -377,3 +377,26 @@ def __init__(
super().__init__(
priors={**priors, **sky_priors}, seed=seed, generator=generator
)


deprecated_vars = {
"isotropic_amplitude_priors": "isotropic_amplitude_distribution",
}


def __getattr__(var_name):

current_module = __import__(__name__)

if var_name not in deprecated_vars:
return getattr(current_module, var_name)

current_name = deprecated_vars[var_name]

logger.warning(
f"Variable `{var_name}` is deprecated"
" and will be removed in a future release."
f" Please use `{current_name}` for any new code."
)

return getattr(current_module, current_name)

0 comments on commit 1458a1f

Please sign in to comment.