Commit a93ccfdb authored by Tjerk Vreeken's avatar Tjerk Vreeken

Fix formatting of default parameters with types

According to Python's formatting rules, default parameters without types
should have no spaces around the equals operator. However, if the type of
a parameter _is_ specified, spaces around the operator are required. See
also PEP-3107 for examples of such code.

Flake8 only started reporting this formatting error starting with version
3.6 (error code E252), causing our test pipeline to fail even though there
were no changes to the codebase. This commit makes sure that the
formatting checks pass again.
parent 89ffc704
......@@ -28,7 +28,7 @@ class LookupTable:
Lookup table.
"""
def __init__(self, inputs: List[ca.MX], function: ca.Function, tck: Tuple=None):
def __init__(self, inputs: List[ca.MX], function: ca.Function, tck: Tuple = None):
"""
Create a new lookup table object.
......
......@@ -21,8 +21,8 @@ class OptimizationProblem(metaclass=ABCMeta):
def __init__(self, **kwargs):
self.__mixed_integer = False
def optimize(self, preprocessing: bool=True, postprocessing: bool=True,
log_solver_failure_as_error: bool=True) -> bool:
def optimize(self, preprocessing: bool = True, postprocessing: bool = True,
log_solver_failure_as_error: bool = True) -> bool:
"""
Perform one initialize-transcribe-solve-finalize cycle.
......@@ -226,7 +226,7 @@ class OptimizationProblem(metaclass=ABCMeta):
pass
@abstractmethod
def extract_results(self, ensemble_member: int=0) -> Dict[str, np.ndarray]:
def extract_results(self, ensemble_member: int = 0) -> Dict[str, np.ndarray]:
"""
Extracts state and control input time series from optimizer results.
......@@ -593,9 +593,9 @@ class OptimizationProblem(metaclass=ABCMeta):
t: Union[float, np.ndarray],
ts: np.ndarray,
fs: np.ndarray,
f_left: float=np.nan,
f_right: float=np.nan,
mode: int=INTERPOLATION_LINEAR) -> Union[float, np.ndarray]:
f_left: float = np.nan,
f_right: float = np.nan,
mode: int = INTERPOLATION_LINEAR) -> Union[float, np.ndarray]:
"""
Linear interpolation over time.
......@@ -725,7 +725,7 @@ class OptimizationProblem(metaclass=ABCMeta):
return []
@abstractmethod
def extract_controls(self, ensemble_member: int=0) -> Dict[str, np.ndarray]:
def extract_controls(self, ensemble_member: int = 0) -> Dict[str, np.ndarray]:
"""
Extracts state time series from optimizer results.
......@@ -737,7 +737,7 @@ class OptimizationProblem(metaclass=ABCMeta):
"""
pass
def control_vector(self, variable: str, ensemble_member: int=0) -> Union[ca.MX, List[ca.MX]]:
def control_vector(self, variable: str, ensemble_member: int = 0) -> Union[ca.MX, List[ca.MX]]:
"""
Return the optimization variables for the entire time horizon of the given state.
......@@ -763,7 +763,7 @@ class OptimizationProblem(metaclass=ABCMeta):
return self.variable(variable)
@abstractmethod
def control_at(self, variable: str, t: float, ensemble_member: int=0, scaled: bool=False) -> ca.MX:
def control_at(self, variable: str, t: float, ensemble_member: int = 0, scaled: bool = False) -> ca.MX:
"""
Returns an :class:`MX` symbol representing the given control input at the given time.
......@@ -812,7 +812,7 @@ class OptimizationProblem(metaclass=ABCMeta):
pass
@abstractmethod
def extract_states(self, ensemble_member: int=0) -> Dict[str, np.ndarray]:
def extract_states(self, ensemble_member: int = 0) -> Dict[str, np.ndarray]:
"""
Extracts state time series from optimizer results.
......@@ -825,7 +825,7 @@ class OptimizationProblem(metaclass=ABCMeta):
pass
@abstractmethod
def state_vector(self, variable: str, ensemble_member: int=0) -> Union[ca.MX, List[ca.MX]]:
def state_vector(self, variable: str, ensemble_member: int = 0) -> Union[ca.MX, List[ca.MX]]:
"""
Return the optimization variables for the entire time horizon of the given state.
......@@ -851,7 +851,7 @@ class OptimizationProblem(metaclass=ABCMeta):
return self.variable(variable)
@abstractmethod
def state_at(self, variable: str, t: float, ensemble_member: int=0, scaled: bool=False) -> ca.MX:
def state_at(self, variable: str, t: float, ensemble_member: int = 0, scaled: bool = False) -> ca.MX:
"""
Returns an :class:`MX` symbol representing the given variable at the given time.
......@@ -867,7 +867,7 @@ class OptimizationProblem(metaclass=ABCMeta):
pass
@abstractmethod
def extra_variable(self, variable: str, ensemble_member: int=0) -> ca.MX:
def extra_variable(self, variable: str, ensemble_member: int = 0) -> ca.MX:
"""
Returns an :class:`MX` symbol representing the extra variable inside the state vector.
......@@ -881,7 +881,7 @@ class OptimizationProblem(metaclass=ABCMeta):
pass
@abstractmethod
def states_in(self, variable: str, t0: float=None, tf: float=None, ensemble_member: int=0) -> Iterator[ca.MX]:
def states_in(self, variable: str, t0: float = None, tf: float = None, ensemble_member: int = 0) -> Iterator[ca.MX]:
"""
Iterates over symbols for states in the interval [t0, tf].
......@@ -895,7 +895,7 @@ class OptimizationProblem(metaclass=ABCMeta):
pass
@abstractmethod
def integral(self, variable: str, t0: float=None, tf: float=None, ensemble_member: int=0) -> ca.MX:
def integral(self, variable: str, t0: float = None, tf: float = None, ensemble_member: int = 0) -> ca.MX:
"""
Returns an expression for the integral over the interval [t0, tf].
......@@ -924,7 +924,7 @@ class OptimizationProblem(metaclass=ABCMeta):
pass
@abstractmethod
def der_at(self, variable: str, t: float, ensemble_member: int=0) -> ca.MX:
def der_at(self, variable: str, t: float, ensemble_member: int = 0) -> ca.MX:
"""
Returns an expression for the time derivative of the specified variable at time t.
......@@ -938,7 +938,7 @@ class OptimizationProblem(metaclass=ABCMeta):
"""
pass
def get_timeseries(self, variable: str, ensemble_member: int=0) -> Timeseries:
def get_timeseries(self, variable: str, ensemble_member: int = 0) -> Timeseries:
"""
Looks up a timeseries from the internal data store.
......@@ -956,9 +956,9 @@ class OptimizationProblem(metaclass=ABCMeta):
self,
variable: str,
timeseries: Timeseries,
ensemble_member: int=0,
output: bool=True,
check_consistency: bool=True) -> None:
ensemble_member: int = 0,
output: bool = True,
check_consistency: bool = True) -> None:
"""
Sets a timeseries in the internal data store.
......@@ -972,7 +972,7 @@ class OptimizationProblem(metaclass=ABCMeta):
"""
raise NotImplementedError
def timeseries_at(self, variable: str, t: float, ensemble_member: int=0) -> float:
def timeseries_at(self, variable: str, t: float, ensemble_member: int = 0) -> float:
"""
Return the value of a time series at the given time.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment