Skip to content

Commit

Permalink
Use None for combination of parameters that are irrelevant rather tha…
Browse files Browse the repository at this point in the history
…n ''
  • Loading branch information
fcharras committed Oct 18, 2023
1 parent 827452a commit 5ca6c70
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
1 change: 0 additions & 1 deletion benchmarks/pca/objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Objective(BaseObjective):
parameters = dict(
n_components=[10],
tol=[0.0],
iterated_power=[15],
n_oversamples=[10],
random_state=[123],
verbose=[False],
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/pca/solvers/scikit_learn.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class Solver(BaseSolver):

parameters = {
"svd_solver, power_iteration_normalizer": [
("full", ""),
("full", None),
("randomized", "LU"),
("arpack", ""),
("arpack", None),
],
"iterated_power": ["auto"],
}
Expand All @@ -34,11 +34,11 @@ def set_objective(
):
if (
self.svd_solver in {"full", "arpack"}
and self.power_iteration_normalizer != ""
and self.power_iteration_normalizer is not None
):
raise ValueError(
f"svd_solver {self.svd_solver} can only run if "
"power_iteration_normalizer parameter is set to 0, but got "
"power_iteration_normalizer parameter is set to None, but got "
f"power_iteration_normalizer={self.power_iteration_normalizer}"
)

Expand All @@ -55,7 +55,7 @@ def set_objective(

def run(self, _):
power_iteration_normalizer = self.power_iteration_normalizer
if power_iteration_normalizer == "":
if power_iteration_normalizer is None:
power_iteration_normalizer = "auto"

estimator = PCA(
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/pca/solvers/scikit_learn_intelex.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ class Solver(BaseSolver):
("gpu", "level_zero"),
],
"svd_solver, power_iteration_normalizer": [
("full", ""),
("full", None),
("randomized", "LU"),
("arpack", ""),
("arpack", None),
],
"iterated_power": ["auto"],
}
Expand Down Expand Up @@ -66,11 +66,11 @@ def set_objective(
):
if (
self.svd_solver in {"full", "arpack"}
and self.power_iteration_normalizer != ""
and self.power_iteration_normalizer is not None
):
raise ValueError(
f"svd_solver {self.svd_solver} can only run if "
"power_iteration_normalizer parameter is set to 0, but got "
"power_iteration_normalizer parameter is set to None, but got "
f"power_iteration_normalizer={self.power_iteration_normalizer}"
)

Expand All @@ -92,7 +92,7 @@ def set_objective(

def run(self, _):
power_iteration_normalizer = self.power_iteration_normalizer
if power_iteration_normalizer == "":
if power_iteration_normalizer is None:
power_iteration_normalizer = "auto"

estimator = PCA(
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/pca/solvers/sklearn_torch_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Solver(BaseSolver):

parameters = {
"svd_solver, power_iteration_normalizer": [
("full", ""),
("full", None),
("randomized", "QR"),
],
"device": ["cpu", "xpu", "cuda", "mps"],
Expand Down Expand Up @@ -61,11 +61,11 @@ def set_objective(
):
if (
self.svd_solver in {"full", "arpack"}
and self.power_iteration_normalizer != ""
and self.power_iteration_normalizer is not None
):
raise ValueError(
f"svd_solver {self.svd_solver} can only run if "
"power_iteration_normalizer parameter is set to 0, but got "
"power_iteration_normalizer parameter is set to None, but got "
f"power_iteration_normalizer={self.power_iteration_normalizer}"
)

Expand All @@ -82,7 +82,7 @@ def set_objective(

def run(self, _):
power_iteration_normalizer = self.power_iteration_normalizer
if power_iteration_normalizer == "":
if power_iteration_normalizer is None:
power_iteration_normalizer = "auto"

with config_context(array_api_dispatch=True):
Expand Down

0 comments on commit 5ca6c70

Please sign in to comment.