Skip to content

Commit

Permalink
random_sketch needs windows specified
Browse files Browse the repository at this point in the history
  • Loading branch information
hanbin973 committed Oct 13, 2024
1 parent 36c10e9 commit 0ac88b8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions python/tskit/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -8603,7 +8603,7 @@ def pca(
iterated_power: int = 5,
num_oversamples: int = 10,
random_seed: int = None,
range_sketch: list = None,
range_sketch: np.ndarray = None,
) -> (np.ndarray, np.ndarray, np.ndarray):
"""
Run randomized singular value decomposition (rSVD) to obtain principal
Expand Down Expand Up @@ -8636,7 +8636,7 @@ def pca(
:param int random_seed: The random seed. If this is None, a random seed will
be automatically generated. Valid random seeds must be between 1 and
:math:`2^32 − 1`.
:param list range_sketch: Sketch matrix for each window. Default is None.
:param np.ndarray range_sketch: Sketch matrix for each window. Default is None.
:return: A tuple (U, D) of ndarrays, with the principal component loadings in U
and the principal values in D.
"""
Expand All @@ -8653,8 +8653,11 @@ def pca(
assert individuals is not None
output_type = "individual"
dim = len(individuals)

if windows is None and range_sketch is not None:
raise ValueError("Windows should be given to supply range_sketch")
if range_sketch is not None:
assert len(range_sketch) == len(windows)
assert range_sketch.shape == len(windows) - 1

if num_components > dim:
raise ValueError(
Expand Down

0 comments on commit 0ac88b8

Please sign in to comment.