Skip to content

Commit

Permalink
change binning warning
Browse files Browse the repository at this point in the history
  • Loading branch information
aronsho committed Feb 18, 2025
1 parent 733f568 commit b0e0187
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
3 changes: 1 addition & 2 deletions seismostats/analysis/avalue/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ def _sanity_checks(self):
'''
# test magnitude binnning
if len(self.magnitudes) > 0:
tolerance = 1e-8
if not binning_test(self.magnitudes, max(self.delta_m, tolerance),
if not binning_test(self.magnitudes, self.delta_m,
check_larger_binning=False):
raise ValueError('Magnitudes are not binned correctly.')

Expand Down
3 changes: 1 addition & 2 deletions seismostats/analysis/bvalue/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ def _sanity_checks(self):
'''
# test magnitude binnning
if len(self.magnitudes) > 0:
tolerance = 1e-8
if not binning_test(self.magnitudes, max(self.delta_m, tolerance),
if not binning_test(self.magnitudes, self.delta_m,
check_larger_binning=False):
raise ValueError('Magnitudes are not binned correctly.')

Expand Down
9 changes: 1 addition & 8 deletions seismostats/utils/binning.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import decimal
import numpy as np
import warnings

from seismostats.utils._config import get_option


def normal_round_to_int(x: float) -> int:
Expand Down Expand Up @@ -125,11 +122,7 @@ def binning_test(

else:
if delta_x < tolerance:
if get_option("warnings") is True:
warnings.warn(
"delta_x is smaller than tolerance, checking"
"for delta_x = " + str(tolerance) + " instead")
delta_x = tolerance
return True
x_binned = bin_to_precision(x, delta_x)

# This test checks if the bins are equal or larger than delta_x.
Expand Down

0 comments on commit b0e0187

Please sign in to comment.