From 41656d1d72a9a8ebaf6dfa6b81745e5b74efafed Mon Sep 17 00:00:00 2001 From: marianolten Date: Wed, 14 Aug 2024 15:13:35 +0200 Subject: [PATCH] run black --- pymrio/tools/iomath.py | 12 ++++--- tests/test_math.py | 74 +++++++++++++----------------------------- 2 files changed, 30 insertions(+), 56 deletions(-) diff --git a/pymrio/tools/iomath.py b/pymrio/tools/iomath.py index c1f02ef6..f966f227 100644 --- a/pymrio/tools/iomath.py +++ b/pymrio/tools/iomath.py @@ -190,7 +190,9 @@ def calc_B(Z, x): # return np.diagflat(recix).dot(Z) if type(Z) is pd.DataFrame: return pd.DataFrame( - np.transpose(np.transpose(Z.values) * recix), index=Z.index, columns=Z.columns + np.transpose(np.transpose(Z.values) * recix), + index=Z.index, + columns=Z.columns, ) else: return np.transpose(np.transpose(Z) * recix) @@ -271,7 +273,9 @@ def calc_G(B, L=None, x=None): if type(L) is pd.DataFrame: return pd.DataFrame( - np.transpose(recix * np.transpose(L.values * x)), index=Z.index, columns=Z.columns + np.transpose(recix * np.transpose(L.values * x)), + index=Z.index, + columns=Z.columns, ) else: # G = hat(x) * L * hat(x)^{-1} in mathematical form hatx.dot(L.transpose()).dot(np.linalg.inv(hatx)). @@ -280,9 +284,7 @@ def calc_G(B, L=None, x=None): else: # calculation of the inverse of I-As has a high computational cost. I = np.eye(B.shape[0]) # noqa if type(B) is pd.DataFrame: - return pd.DataFrame( - np.linalg.inv(I - B), index=B.index, columns=B.columns - ) + return pd.DataFrame(np.linalg.inv(I - B), index=B.index, columns=B.columns) else: return np.linalg.inv(I - B) # G = inverse matrix of (I - B) diff --git a/tests/test_math.py b/tests/test_math.py index 8f9a9a55..b235759d 100644 --- a/tests/test_math.py +++ b/tests/test_math.py @@ -243,48 +243,20 @@ class IO_Data: 0.01960784, 0.11764706, 0.09803922, - 0.1372549 - ], # noqa - [ - 0.0, - 0.13333333, - 0.0, - 0.0, - 0.33333333, - 0.2 + 0.1372549, ], # noqa + [0.0, 0.13333333, 0.0, 0.0, 0.33333333, 0.2], # noqa [ 0.17241379, 0.05172414, 0.34482759, 0.06896552, 0.03448276, - 0. - ], # noqa - [ - 0.1, 0.0, - 0.0, - 0.02, - 0.2, - 0.18 ], # noqa - [ - 0.0, - 0.19230769, - 0.01923077, - 0.0, - 0.38461538, - 0.01923077 - ], # noqa - [ - 0.12820513, - 0.0, - 0.0, - 0.02564103, - 0.25641026, - 0.25641026 - ] + [0.1, 0.0, 0.0, 0.02, 0.2, 0.18], # noqa + [0.0, 0.19230769, 0.01923077, 0.0, 0.38461538, 0.01923077], # noqa + [0.12820513, 0.0, 0.0, 0.02564103, 0.25641026, 0.25641026], ], index=_Z_multiindex, columns=_Z_multiindex, @@ -351,33 +323,33 @@ class IO_Data: 1.33871463, 0.28499301, 0.05727924, - 0.1747153 , + 0.1747153, 0.58648041, - 0.38121958 - ], # noqa - [ + 0.38121958, + ], # noqa + [ 0.07482651, 1.37164729, 0.02969614, 0.02185805, 0.93542302, - 0.41222074 - ], # noqa - [ - 0.38065717, - 0.22311379, - 1.54929428, - 0.15941084, - 0.39473223, - 0.17907022 - ], # noqa + 0.41222074, + ], # noqa + [ + 0.38065717, + 0.22311379, + 1.54929428, + 0.15941084, + 0.39473223, + 0.17907022, + ], # noqa [ 0.19175489, 0.15732254, 0.02349465, 1.05420074, 0.60492361, - 0.34854312 + 0.34854312, ], # noqa [ 0.04316348, @@ -385,7 +357,7 @@ class IO_Data: 0.05866155, 0.01404088, 1.95452858, - 0.18081884 + 0.18081884, ], # noqa [ 0.25230906, @@ -393,8 +365,8 @@ class IO_Data: 0.03091401, 0.07131676, 0.79595212, - 1.48492515 - ] + 1.48492515, + ], ], index=_Z_multiindex, columns=_Z_multiindex,