Skip to content

Commit

Permalink
Try to fix gh actions for alternative fluid wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Sep 26, 2023
1 parent 191d2e8 commit 16bd9f4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 37 deletions.
63 changes: 29 additions & 34 deletions src/tespy/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)

Expand All @@ -210,35 +204,39 @@ 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)

elif key in ['local_design', 'local_offdesign',
'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)

Expand All @@ -255,17 +253,16 @@ 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)

self.new_design = True

# 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)

Expand All @@ -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)

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/tespy/networks/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ setenv =
passenv =
*
deps =
pytest
.[dev]
commands =
{posargs:pytest -vv --ignore=src}

Expand Down

0 comments on commit 16bd9f4

Please sign in to comment.