Skip to content

Commit

Permalink
Make more parameters optional
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-czech committed Sep 30, 2020
1 parent 6dee80e commit 28a9b49
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions sgkit/stats/pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,28 @@ def pca_est(
n_components: int = 10,
*,
ploidy: Optional[int] = None,
scaler: Union[BaseEstimator, str] = "patterson",
algorithm: Literal["tsqr", "randomized"] = "tsqr",
scaler: Optional[Union[BaseEstimator, str]] = None,
algorithm: Optional[Literal["tsqr", "randomized"]] = None,
n_iter: int = 0,
random_state: RandomStateType = 0,
variable: str = "call_alternate_allele_count",
) -> BaseEstimator:
""" Create PCA estimator """
if not ploidy:
if ploidy is None:
if "ploidy" not in ds.dims:
raise ValueError(
"`ploidy` must be specified explicitly when not present in dataset dimensions"
)
ploidy = ds.dims["ploidy"]
if scaler is None:
scaler = "patterson"
if isinstance(scaler, str):
if scaler != "patterson":
raise ValueError(
f"Only 'patterson' scaler currently supported (not '{scaler}')"
)
if algorithm is None:
algorithm = "tsqr"
if algorithm not in ["tsqr", "randomized"]:
raise ValueError(
f"`algorithm` must be one of ['tsqr', 'randomized'] (not '{algorithm}')"
Expand Down Expand Up @@ -133,8 +137,8 @@ def pca(
n_components: int = 10,
*,
ploidy: Optional[int] = None,
scaler: Union[BaseEstimator, str] = "patterson",
algorithm: Literal["tsqr", "randomized"] = "tsqr",
scaler: Optional[Union[BaseEstimator, str]] = None,
algorithm: Optional[Literal["tsqr", "randomized"]] = None,
n_iter: int = 0,
random_state: RandomStateType = 0,
variable: str = "call_alternate_allele_count",
Expand All @@ -154,7 +158,7 @@ def pca(
dimension in provided dataset if not passed explicitly.
scaler
Scaler implementation used to normalize alternate allele counts, by default 'patterson'.
This is currently the only supported scaler, but a custom estimator may also be passed.
This is currently the only supported scaler but a custom estimator may also be passed.
See ``sgkit.stats.preprocessing.PattersonScaler`` for more details.
algorithm
Name of SVD algorithm to use, by default "tsqr". Must be in ["tsqr", "randomized"].
Expand Down

0 comments on commit 28a9b49

Please sign in to comment.