Skip to content

Commit

Permalink
Merge 4b59e55 into b2f9106
Browse files Browse the repository at this point in the history
  • Loading branch information
fwitte committed Jan 31, 2019
2 parents b2f9106 + 4b59e55 commit ac5a9ef
Show file tree
Hide file tree
Showing 14 changed files with 1,467 additions and 543 deletions.
240 changes: 120 additions & 120 deletions doc/api/_images/heat_pump_COP_air.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
242 changes: 121 additions & 121 deletions doc/api/_images/heat_pump_COP_water.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 20 additions & 3 deletions tespy/components/characteristics.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ def __init__(self, **kwargs):
if self.y is None:
self.y = self.default(method)[1]

if isinstance(self.x, list):
self.x = np.array(self.x)
if isinstance(self.y, list):
self.y = np.array(self.y)

if len(self.x) != len(self.y):
msg = ('Please provide the same amount of x-values and y-values. Number of x-values: ' +
str(len(self.x)) + ', number of y-values: ' + str(len(self.y)) + '.')
Expand Down Expand Up @@ -391,7 +396,10 @@ def get_attr(self, key):
if key in self.__dict__:
return self.__dict__[key]
else:
return None
msg = 'Characteristics has no attribute \"' + key + '\".'
logging.error(msg)
raise KeyError(msg)


# %%

Expand Down Expand Up @@ -453,12 +461,21 @@ def __init__(self, **kwargs):
if self.z2 is None:
self.z2 = self.default(method)[3]

if np.array(self.x).shape[0] != np.array(self.y).shape[0]:
if isinstance(self.x, list):
self.x = np.array(self.x)
if isinstance(self.y, list):
self.y = np.array(self.y)
if isinstance(self.z1, list):
self.z1 = np.array(self.z1)
if isinstance(self.z2, list):
self.z2 = np.array(self.z2)

if self.x.shape[0] != self.y.shape[0]:
msg = ('The number of x-values determines the number of dimension for the characteristic map. You have provided ' +
str(len(self.x)) + 'x-values. Thus, the y-, z1- and z2-arrays must have ' + str(len(self.x)) +' number of dimensions.')
logging.error(msg)
raise ValueError(msg)
elif np.array(self.y).shape != np.array(self.z1).shape or np.array(self.y).shape != np.array(self.z2).shape:
elif self.y.shape != self.z1.shape or self.y.shape != self.z2.shape:
msg = 'Make sure that the number of dimensions and the number of values in the y-, z1- and z2-arrays are identical!'
logging.error(msg)
raise ValueError(msg)
Expand Down
Loading

0 comments on commit ac5a9ef

Please sign in to comment.