Skip to content
Snippets Groups Projects
Commit b65f6ae6 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Apply suggestion to bilby/core/utils.py

parent 76240cfd
No related branches found
No related tags found
1 merge request!604Hotfix for dynesty bounds
Pipeline #81231 passed
......@@ -1005,6 +1005,26 @@ def decode_astropy_quantity(dct):
def reflect(u):
"""
Iteratively reflect a number until it is contained in [0, 1].
This is for priors with a reflective boundary condition, all numbers in the set `u = 2n +/- x` should be mapped to x.
For the `+` case we just take `u % 1`.
For the `-` case we take `1 - (u % 1)`.
E.g., -0.9, 1.1, and 2.9 should all map to 0.9.
Parameters
----------
u: array-like
The array of points to map to the unit cube
Returns
-------
u: array-like
The input array, modified in place.
"""
idxs_even = np.mod(u, 2) < 1
u[idxs_even] = np.mod(u[idxs_even], 1)
u[~idxs_even] = 1 - np.mod(u[~idxs_even], 1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment