From 5e4112e68be8ed6cf2770ede026ceb89fcb0d3bb Mon Sep 17 00:00:00 2001 From: Vincent R Date: Sun, 26 Nov 2023 11:22:49 +0100 Subject: [PATCH] Adding UserWarning in case of singular matrix. --- skrf/network.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skrf/network.py b/skrf/network.py index 260669828..ecf562220 100644 --- a/skrf/network.py +++ b/skrf/network.py @@ -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 @@ -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