From 95e923d7b71f46f2e7b36b616c1b29e219275811 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Mon, 29 Jul 2024 00:32:03 -0700 Subject: [PATCH] improve error handling --- meanas/fdfd/bloch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meanas/fdfd/bloch.py b/meanas/fdfd/bloch.py index 427e1a5..cd2ae16 100644 --- a/meanas/fdfd/bloch.py +++ b/meanas/fdfd/bloch.py @@ -657,7 +657,7 @@ def eigsolve( Q = c * c * ZtZ + s * s * DtD + 2 * s * c * symZtD try: Qi = numpy.linalg.inv(Q) - except numpy.linalg.LinAlgError: + except numpy.linalg.LinAlgError as err: logger.info('taylor Qi') # if c or s small, taylor expand if c < 1e-4 * s and c != 0: @@ -667,7 +667,7 @@ def eigsolve( ZtZi = numpy.linalg.inv(ZtZ) Qi = ZtZi / (c * c) - 2 * s / (c * c * c) * (ZtZi @ (ZtZi @ symZtD).conj().T) else: - raise Exception('Inexplicable singularity in trace_func') + raise Exception('Inexplicable singularity in trace_func') from err Qi_memo[0] = theta Qi_memo[1] = cast(float, Qi) return cast(float, Qi)