From a85db7897836dd57c2690c8ab9133184ab656c2f Mon Sep 17 00:00:00 2001 From: Aron Mirwald Date: Mon, 17 Feb 2025 20:25:01 +0900 Subject: [PATCH] test for length list_mc and include indexError --- seismostats/analysis/b_significant.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/seismostats/analysis/b_significant.py b/seismostats/analysis/b_significant.py index 966b387..1b98dbb 100644 --- a/seismostats/analysis/b_significant.py +++ b/seismostats/analysis/b_significant.py @@ -197,13 +197,16 @@ def values_from_partitioning( # sanity checks n_subsets = len(list_magnitudes) if n_subsets != len(list_times): - raise ValueError( + raise IndexError( "Length of list_times and list_magnitudes must be the same.") list_magnitudes = [np.array(mags) for mags in list_magnitudes] list_times = [np.array(times) for times in list_times] if isinstance(list_mc, (float, int)): list_mc = np.ones(n_subsets) * list_mc else: + if n_subsets != len(list_mc): + raise IndexError( + "Length of list_mc must be the same as list_magnitudes.") list_mc = np.array(list_mc) # start estimation @@ -347,7 +350,7 @@ def b_significant_1D( "The number of subsamples is less than 25. The normality " "assumption of the autocorrelation might not be valid.") if len(mags) != len(times): - raise ValueError("Magnitudes and times must have the same length.") + raise IndexError("Magnitudes and times must have the same length.") # Estimate a and b values for n_m realizations. ac_1D = np.zeros(n_m)