Skip to content

Commit

Permalink
Simplify check_efficient
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
IlhaH and coderabbitai[bot] committed Jul 19, 2024
1 parent 77e83c4 commit 3b9ae42
Showing 1 changed file with 4 additions and 33 deletions.
37 changes: 4 additions & 33 deletions python/python/bystro/covariance/hypothesis_hd.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,41 +117,12 @@ def t_func(lambda_: np.ndarray, gamma: float, eta0: float) -> float:
)


def check_efficient(
gamma: float,
lambda1: np.ndarray,
lambda2: np.ndarray,
epsilon: float = 0.05,
) -> bool:
"""
Check if the splitting is efficient.
Parameters
----------
gamma : float
Gamma value.
lambda1 : np.ndarray
First array of eigenvalues.
lambda2 : np.ndarray
Second array of eigenvalues.
epsilon : float, optional
Tolerance value, by default 0.05.
Returns
-------
is_efficient : bool
True if efficient, False otherwise.
"""
range1 = abs(lambda1[0] - lambda1[-1])
range2 = abs(lambda2[0] - lambda2[-1])
if (
max(abs(gamma - lambda1[0]), abs(gamma - lambda1[-1]))
> range1 - epsilon
or max(abs(gamma - lambda2[0]), abs(gamma - lambda2[-1]))
> range2 - epsilon
):
return False
return True
return not (
max(abs(gamma - lambda1[0]), abs(gamma - lambda1[-1])) > range1 - epsilon
or max(abs(gamma - lambda2[0]), abs(gamma - lambda2[-1])) > range2 - epsilon
)


def two_sample_test_(
Expand Down

0 comments on commit 3b9ae42

Please sign in to comment.