utils.bin_to_precision#

seismostats.utils.bin_to_precision(x: ndarray | list, delta_x: float) ndarray#

Rounds float numbers within the array x to a given precision. If precision is not given, an error is raised.

Parameters:
  • x – List of decimal numbers that needs to be rounded.

  • delta_x – Size of the bin.

Returns:

x_round – Value rounded to the given precision.

Examples

>>> from seismostats.utils import bin_to_precision
>>> bin_to_precision([1.234, 2.345, 3.456], 0.1)
array([1.2, 2.3, 3.5])
>>> bin_to_precision([1.234, 2.345, 3.456], 0.01)
array([1.23, 2.35, 3.46])

See also

normal_round()