Skip to content

Commit

Permalink
Adding UserWarning in case of singular matrix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinc0110 committed Nov 26, 2023
1 parent 5b8c14c commit 5e4112e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions skrf/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -6339,6 +6339,8 @@ def z2y(z: npy.ndarray) -> npy.ndarray:
if npy.amin(npy.linalg.matrix_rank(z)) < npy.shape(z)[1]:
# matrix is deficient, direct inversion not possible
# try detour via S parameters
warnings.warn('The Z matrix is singular. Conversion to Y parameters could be invalid. Trying s2y(z2s(z)).',
UserWarning, stacklevel=2)
return s2y(z2s(z))
else:
# matrix has full rank, direct inversion possible
Expand Down Expand Up @@ -6733,6 +6735,8 @@ def y2z(y: npy.ndarray) -> npy.ndarray:
if npy.amin(npy.linalg.matrix_rank(y)) < npy.shape(y)[1]:
# matrix is deficient, direct inversion not possible
# try detour via S parameters
warnings.warn('The Y matrix is singular. Conversion to Z parameters could be invalid. Trying s2z(y2s(y)).',
UserWarning, stacklevel=2)
return s2z(y2s(y))
else:
# matrix has full rank, direct inversion possible
Expand Down

0 comments on commit 5e4112e

Please sign in to comment.