[Feat] More specific Exception statements (#287)

* [Feat] More specific Exception statements

* [Fix] Address copilot comments
This commit is contained in:
Fabian Joswig 2026-07-06 16:36:56 +02:00 committed by GitHub
commit 470e2c57fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 73 additions and 73 deletions

View file

@ -35,7 +35,7 @@ def matrix_pencil_method(corrs, k=1, p=None, **kwargs):
lengths = [len(d) for d in data]
if lengths.count(lengths[0]) != len(lengths):
raise Exception('All datasets have to have the same length.')
raise ValueError('All datasets have to have the same length.')
data_sets = len(data)
n_data = len(data[0])
@ -43,9 +43,9 @@ def matrix_pencil_method(corrs, k=1, p=None, **kwargs):
if p is None:
p = max(n_data // 2, k)
if n_data <= p:
raise Exception('The pencil p has to be smaller than the number of data samples.')
raise ValueError('The pencil p has to be smaller than the number of data samples.')
if p < k or n_data - p < k:
raise Exception('Cannot extract', k, 'energy levels with p=', p, 'and N-p=', n_data - p)
raise ValueError(f'Cannot extract {k} energy levels with p={p} and N-p={n_data - p}')
# Construct the hankel matrices
matrix = []