From 16bd9f44d0301bdf83d0859167be3576e9e6c061 Mon Sep 17 00:00:00 2001 From: Francesco Witte Date: Tue, 26 Sep 2023 17:44:03 +0200 Subject: [PATCH] Try to fix gh actions for alternative fluid wrappers --- src/tespy/components/component.py | 63 ++++++++++++++----------------- src/tespy/networks/network.py | 4 +- tox.ini | 2 +- 3 files changed, 32 insertions(+), 37 deletions(-) diff --git a/src/tespy/components/component.py b/src/tespy/components/component.py index 8fada329a..8b8bafd1c 100644 --- a/src/tespy/components/component.py +++ b/src/tespy/components/component.py @@ -176,18 +176,11 @@ def set_attr(self, **kwargs): # value specification for component properties elif isinstance(data, dc_cp) or isinstance(data, dc_simple): if is_numeric: - if np.isnan(kwargs[key]): - data.set_attr(is_set=False) - if isinstance(data, dc_cp): - data.set_attr(is_var=False) - - else: - data.set_attr(val=kwargs[key], is_set=True) - if isinstance(data, dc_cp): - data.set_attr(is_var=False) - - elif (kwargs[key] == 'var' and - isinstance(data, dc_cp)): + data.set_attr(val=kwargs[key], is_set=True) + if isinstance(data, dc_cp): + data.set_attr(is_var=False) + + elif kwargs[key] == 'var' and isinstance(data, dc_cp): data.set_attr(is_set=True, is_var=True) elif isinstance(data, dc_simple): @@ -196,8 +189,9 @@ def set_attr(self, **kwargs): # invalid datatype for keyword else: msg = ( - 'Bad datatype for keyword argument ' + key + - ' at ' + self.label + '.') + f"Bad datatype for keyword argument {key} for " + f"component {self.label}." + ) logger.error(msg) raise TypeError(msg) @@ -210,26 +204,29 @@ def set_attr(self, **kwargs): # invalid datatype for keyword else: msg = ( - 'Bad datatype for keyword argument ' + key + - ' at ' + self.label + '.') + f"Bad datatype for keyword argument {key} for " + f"component {self.label}." + ) logger.error(msg) raise TypeError(msg) elif key in ['design', 'offdesign']: if not isinstance(kwargs[key], list): msg = ( - 'Please provide the ' + key + ' parameters as list ' - 'at ' + self.label + '.') + f"Please provide the {key} parameters as list for " + f"component {self.label}." + ) logger.error(msg) raise TypeError(msg) if set(kwargs[key]).issubset(list(self.parameters.keys())): self.__dict__.update({key: kwargs[key]}) else: + keys = ", ".join(self.parameters.keys()) msg = ( - 'Available parameters for (off-)design specification ' - 'are: ' + str(list(self.parameters.keys())) + ' at ' + - self.label + '.') + "Available parameters for (off-)design specification " + f"of component {self.label} are: {keys}." + ) logger.error(msg) raise ValueError(msg) @@ -237,8 +234,9 @@ def set_attr(self, **kwargs): 'printout', 'char_warnings']: if not isinstance(kwargs[key], bool): msg = ( - 'Please provide the parameter ' + key + ' as boolean ' - 'at component ' + self.label + '.') + f"Please provide the {key} parameters as bool for " + f"component {self.label}." + ) logger.error(msg) raise TypeError(msg) @@ -255,7 +253,8 @@ def set_attr(self, **kwargs): else: msg = ( 'Please provide the design_path parameter as string. ' - 'For unsetting use np.nan or None.') + 'For unsetting use None.' + ) logger.error(msg) raise TypeError(msg) @@ -263,9 +262,7 @@ def set_attr(self, **kwargs): # invalid keyword else: - msg = ( - 'Component ' + self.label + ' has no attribute ' + - str(key) + '.') + msg = f"Component {self.label} has no attribute {key}." logger.error(msg) raise KeyError(msg) @@ -286,8 +283,7 @@ def get_attr(self, key): if key in self.__dict__: return self.__dict__[key] else: - msg = ('Component ' + self.label + ' has no attribute \"' + - key + '\".') + msg = f"Component {self.label} has no attribute {key}." logger.error(msg) raise KeyError(msg) @@ -429,9 +425,7 @@ def preprocess(self, num_nw_vars): sum_eq += num_eq # done - msg = ( - f"The component {self.label} has {self.num_vars} custom variables." - ) + msg = f"The component {self.label} has {self.num_vars} variables." logger.debug(msg) def get_parameters(self): @@ -501,8 +495,9 @@ def get_char_expr(self, param, type='rel', inconn=0, outconn=0): self.outl[outconn].p.design)) else: msg = ( - 'The parameter ' + str(param) + ' is not available ' - 'for characteristic function evaluation.') + f"The parameter {param}) is not available for " + "characteristic function evaluation." + ) logger.error(msg) raise ValueError(msg) else: diff --git a/src/tespy/networks/network.py b/src/tespy/networks/network.py index 4cd8b40c3..103e1c9e9 100644 --- a/src/tespy/networks/network.py +++ b/src/tespy/networks/network.py @@ -384,7 +384,7 @@ def get_conn(self, label): try: return self.conns.loc[label, 'object'] except KeyError: - logger.warning('Connection with label %s not found.', label) + logger.warning(f"Connection with label {label} not found.") return None def get_comp(self, label): @@ -586,7 +586,7 @@ def add_ude(self, *args): raise ValueError(msg) self.user_defined_eq[c.label] = c - msg = 'Added UserDefinedEquation ' + c.label + ' to network.' + msg = f"Added UserDefinedEquation {c.label} to network." logger.debug(msg) def del_ude(self, *args): diff --git a/tox.ini b/tox.ini index 890bc4ad0..8e5d3fd79 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,7 @@ setenv = passenv = * deps = - pytest + .[dev] commands = {posargs:pytest -vv --ignore=src}