Skip to content

Commit

Permalink
Merge pull request #343 from mj-will/fix-bilby-slowdown
Browse files Browse the repository at this point in the history
Address slowdown in bilby analyses with v0.10.0
  • Loading branch information
mj-will authored Nov 9, 2023
2 parents 2530a6b + 8185d02 commit c3afc0f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nessai/utils/multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def batch_evaluate_function(
return out


def check_vectorised_function(func, x, dtype=None):
def check_vectorised_function(func, x, dtype=None, atol=1e-15, rtol=1e-15):
"""Check if a function is vectorised given a set of inputs.
Parameters
Expand All @@ -186,6 +186,10 @@ def check_vectorised_function(func, x, dtype=None):
dtype : Optional[Union[str, numpy.dtype]]
Dtype to cast the results to. If not specified, the default dtype
for livepoints is used.
rtol : float
Relative tolerance, see numpy documentation for :code:`allclose`.
atol : float
Abosoulte tolerance, see numpy documentation for :code:`allclose`.
Returns
-------
Expand All @@ -205,7 +209,7 @@ def check_vectorised_function(func, x, dtype=None):
logger.debug("Assuming function is not vectorised")
return False
else:
if np.array_equal(target, batch):
if np.allclose(target, batch, atol=atol, rtol=rtol):
logger.debug("Function is vectorised")
return True
else:
Expand Down

0 comments on commit c3afc0f

Please sign in to comment.