Skip to content

Commit

Permalink
Style fix for LookupTable class
Browse files Browse the repository at this point in the history
A method in OptimizationProblem was returning a "LookupTable" type, with
the class not defined anywhere in scope. One of the CI/CD style checkers
became a bit more aggressive recently and started to catch this as an
error.

We now properly defined a base LookupTable class, from which the one in
csv_lookup_table_mixin.py inherits.
  • Loading branch information
Tjerk Vreeken committed Jun 8, 2020
1 parent 9224d21 commit d3146a7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/rtctools/optimization/csv_lookup_table_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
from scipy.interpolate import bisplev, bisplrep, splev
from scipy.optimize import brentq

from .optimization_problem import LookupTable as LookupTableBase
from .optimization_problem import OptimizationProblem

logger = logging.getLogger("rtctools")


class LookupTable:
class LookupTable(LookupTableBase):
"""
Lookup table.
"""
Expand Down
22 changes: 21 additions & 1 deletion src/rtctools/optimization/optimization_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@
BT = Union[float, np.ndarray, Timeseries]


class LookupTable(metaclass=ABCMeta):
"""
Base class for LookupTables.
"""

@property
def inputs(self) -> List[ca.MX]:
"""
List of lookup table input variables.
"""
raise NotImplementedError

@property
def function(self) -> ca.Function:
"""
Lookup table CasADi :class:`Function`.
"""
raise NotImplementedError


class OptimizationProblem(DataStoreAccessor, metaclass=ABCMeta):
"""
Base class for all optimization problems.
Expand Down Expand Up @@ -389,7 +409,7 @@ def constant_inputs(self, ensemble_member: int) -> AliasDict[str, Timeseries]:
"""
return AliasDict(self.alias_relation)

def lookup_tables(self, ensemble_member: int) -> AliasDict[str, 'LookupTable']:
def lookup_tables(self, ensemble_member: int) -> AliasDict[str, LookupTable]:
"""
Returns a dictionary of lookup tables.
Expand Down

0 comments on commit d3146a7

Please sign in to comment.