diff --git a/docs/user_guide/neuroevolution.md b/docs/user_guide/neuroevolution.md index 60aa86a..d0c3620 100644 --- a/docs/user_guide/neuroevolution.md +++ b/docs/user_guide/neuroevolution.md @@ -293,8 +293,7 @@ class CustomNE(NEProblem): def _network_constants(self): return {"d": self._d} # Pass self._d as 'd' to networks at instantiation - def _evaluate_network(self, network: torch.nn.Module): - ... + def _evaluate_network(self, network: torch.nn.Module): ... ``` which then allows, for example, the use of the variable `d` in the string representation of the network diff --git a/src/evotorch/algorithms/functional/__init__.py b/src/evotorch/algorithms/functional/__init__.py index 25ab468..71723e2 100644 --- a/src/evotorch/algorithms/functional/__init__.py +++ b/src/evotorch/algorithms/functional/__init__.py @@ -256,8 +256,7 @@ def f(x: torch.Tensor) -> torch.Tensor: class MyProblem(Problem): - def __init__(self): - ... + def __init__(self): ... def _evaluate_batch(self, batch: SolutionBatch): # Stateful batch evaluation code goes here diff --git a/src/evotorch/core.py b/src/evotorch/core.py index f44d0ef..e2b4324 100644 --- a/src/evotorch/core.py +++ b/src/evotorch/core.py @@ -610,8 +610,9 @@ def __init__(self): # for initializing solutions ) - def _evaluate_batch(self, solutions: SolutionBatch): - ... # code to compute and fill the fitnesses goes here + def _evaluate_batch( + self, solutions: SolutionBatch + ): ... # code to compute and fill the fitnesses goes here def _fill(self, values: torch.Tensor): # `values` is an empty tensor of shape (n, m) where n is the number @@ -749,8 +750,7 @@ def _evaluate_batch(self, solutions: SolutionBatch): from evotorch.logging import StdOutLogger - def f(x: torch.Tensor) -> torch.Tensor: - ... + def f(x: torch.Tensor) -> torch.Tensor: ... prob = Problem("min", f, solution_length=..., dtype=torch.float32) diff --git a/src/evotorch/decorators.py b/src/evotorch/decorators.py index 796ad21..d8e40c0 100644 --- a/src/evotorch/decorators.py +++ b/src/evotorch/decorators.py @@ -254,8 +254,7 @@ def f(x: torch.Tensor) -> torch.Tensor: @on_device("cuda") - def f(x: torch.Tensor) -> torch.Tensor: - ... + def f(x: torch.Tensor) -> torch.Tensor: ... problem = Problem( @@ -306,8 +305,7 @@ def _evaluate_batch(self, solutions: SolutionBatch): ```python @on_device("cpu") - def f(x: torch.Tensor) -> torch.Tensor: - ... + def f(x: torch.Tensor) -> torch.Tensor: ... print(f.device) # Prints: torch.device("cpu") @@ -499,8 +497,7 @@ def f(x: torch.Tensor) -> torch.Tensor: @on_aux_device - def f(x: torch.Tensor) -> torch.Tensor: - ... + def f(x: torch.Tensor) -> torch.Tensor: ... problem = Problem( @@ -632,8 +629,7 @@ def expects_ndim( # noqa: C901 @expects_ndim(2, 1) - def f(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor: - ... + def f(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor: ... ``` Once decorated like this, the function `f` will gain the following @@ -663,8 +659,7 @@ def f(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor: ```python @expects_ndim(2, 1, randomness="error") - def f(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor: - ... + def f(a: torch.Tensor, b: torch.Tensor) -> torch.Tensor: ... ``` If `randomness` is set as "error", then, when there is batching, any @@ -941,8 +936,7 @@ def fitness(decision_values: torch.Tensor) -> torch.Tensor: ```python @rowwise(randomness="error") - def f(x: torch.Tensor) -> torch.Tensor: - ... + def f(x: torch.Tensor) -> torch.Tensor: ... ``` If `randomness` is set as "error", then, when there is batching, any diff --git a/src/evotorch/distributions.py b/src/evotorch/distributions.py index 5af9214..2636a3e 100644 --- a/src/evotorch/distributions.py +++ b/src/evotorch/distributions.py @@ -1395,8 +1395,7 @@ def make_functional_grad_estimator( ) - def f(x: torch.Tensor) -> torch.Tensor: - ... + def f(x: torch.Tensor) -> torch.Tensor: ... fgrad = make_functional_grad_estimator(