Skip to content

Commit

Permalink
formatting correction in iomath.py
Browse files Browse the repository at this point in the history
  • Loading branch information
BeckebanzeF1 committed Feb 28, 2024
1 parent 119ec5d commit 8984f0b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pymrio/tools/iomath.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,19 @@ def calc_G(As, L=None, x=None):
recix = recix.reshape((1, -1))

if type(L) is pd.DataFrame:
return pd.DataFrame(recix * np.transpose(L.values * x), index=Z.index, columns=Z.columns)
return pd.DataFrame(
recix * np.transpose(L.values * x), index=Z.index, columns=Z.columns
)
else:
# G = hat(x)^{-1} * L^T * hat(x) in mathematical form np.linalg.inv(hatx).dot(L.transpose()).dot(hatx).
# it is computationally much faster to multiply element-wise because hatx is a diagonal matrix.
return recix * np.transpose(L * x)
else: # calculation of the inverse of I-As has a high computational cost.
I = np.eye(As.shape[0]) # noqa
if type(As) is pd.DataFrame:
return pd.DataFrame(np.linalg.inv(I - As), index=As.index, columns=As.columns)
return pd.DataFrame(
np.linalg.inv(I - As), index=As.index, columns=As.columns
)
else:
return np.linalg.inv(I - As) # G = inverse matrix of (I - As)

Expand Down

0 comments on commit 8984f0b

Please sign in to comment.