Skip to content

Commit

Permalink
rename variable and clean docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
mcw92 committed May 13, 2024
1 parent 0ae4142 commit 511f086
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions propulate/propagators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def __call__(self, *inds: Individual) -> Individual:
ValueError
If a parameter's type is invalid, i.e., not float (continuous), int (ordinal), or str (categorical).
"""
ind = {}
position = {}
if (
self.rng.random() < self.probability
): # Apply only with specified probability.
Expand All @@ -540,21 +540,21 @@ def __call__(self, *inds: Individual) -> Individual:
if isinstance(
self.limits[limit][0], int
): # If ordinal trait of type integer.
ind[limit] = self.rng.randint(*self.limits[limit])
position[limit] = self.rng.randint(*self.limits[limit])
elif isinstance(
self.limits[limit][0], float
): # If interval trait of type float.
ind[limit] = self.rng.uniform(*self.limits[limit])
position[limit] = self.rng.uniform(*self.limits[limit])
elif isinstance(
self.limits[limit][0], str
): # If categorical trait of type string.
ind[limit] = self.rng.choice(self.limits[limit])
position[limit] = self.rng.choice(self.limits[limit])
else:
raise ValueError(
"Unknown type of limits. Has to be float for interval, "
"int for ordinal, or string for categorical."
)
ind = Individual(ind, self.limits) # Instantiate new individual.
ind = Individual(position, self.limits) # Instantiate new individual.
else: # Return first input individual w/o changes otherwise.
ind = inds[0]
return ind
Expand All @@ -570,16 +570,16 @@ def __init__(
rng: np.random.Generator,
):
"""
Initialize gaussian propagator.
Initialize Gaussian propagator.
Parameters
----------
limits: dict[str, tuple[float, float]] | dict[str, tuple[int, int]] | dict[str, tuple[str, ...]]
search space, i.e., limits of (hyper-)parameters to be optimized
scale: float
standard deviation
rng: random.Random
random number generator
limits : Dict[str, Tuple[float, float]] | Dict[str, Tuple[int, int]] | Dict[str, Tuple[str, ...]]
The search space, i.e., limits of (hyper-)parameters to be optimized.
scale : float
The standard deviation of the Gaussian distribution.
rng : random.Random
The separate random number generator for the Propulate optimization.
"""
super().__init__(1, 1)
Expand All @@ -589,7 +589,7 @@ def __init__(

def __call__(self, inds: List[Individual]) -> Individual:
"""
Apply the gaussian propagator.
Apply the Gaussian propagator.
Parameters
----------
Expand Down

0 comments on commit 511f086

Please sign in to comment.