Skip to content

Commit

Permalink
Fix test case by removing seed parameter from `random_matrix_with_con…
Browse files Browse the repository at this point in the history
…dition_number`.
  • Loading branch information
Markus Semmler committed Aug 12, 2023
1 parent a0f094d commit 4a8559f
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/pydvl/utils/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,7 @@ def random_subset_of_size(
return rng.choice(s, size=size, replace=False)


def random_matrix_with_condition_number(
n: int,
condition_number: float,
seed: SeedOrGenerator = None,
) -> NDArray:
def random_matrix_with_condition_number(n: int, condition_number: float) -> NDArray:
"""Constructs a square matrix with a given condition number.
Taken from:
Expand All @@ -157,10 +153,8 @@ def random_matrix_with_condition_number(
:param n: size of the matrix
:param condition_number: duh
:param seed: Seed for the random number generator.
:return: An (n,n) matrix with the requested condition number.
"""
rng = np.random.default_rng(seed)
if n < 2:
raise ValueError("Matrix size must be at least 2")

Expand All @@ -176,8 +170,8 @@ def random_matrix_with_condition_number(
exp_vec = exp_vec[:n]
s: np.ndarray = np.exp(exp_vec)
S = np.diag(s)
U, _ = np.linalg.qr((rng.random((n, n)) - 5.0) * 200)
V, _ = np.linalg.qr((rng.random((n, n)) - 5.0) * 200)
U, _ = np.linalg.qr((np.random.rand(n, n) - 5.0) * 200)
V, _ = np.linalg.qr((np.random.rand(n, n) - 5.0) * 200)
P: np.ndarray = U.dot(S).dot(V.T)
P = P.dot(P.T)
return P
Expand Down

0 comments on commit 4a8559f

Please sign in to comment.