Skip to content

Commit

Permalink
test for length list_mc and include indexError
Browse files Browse the repository at this point in the history
  • Loading branch information
aronsho committed Feb 17, 2025
1 parent 259ae15 commit a85db78
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions seismostats/analysis/b_significant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit a85db78

Please sign in to comment.