numerics#

class cosmicjellyfish.utilities.utils.numerics[source]#

Bases: object

static round_decimals_up(number, decimals=2, precision=5)[source]#

Returns a value rounded up to a specific number of decimal places.

static bisection(array, value)[source]#

Given an array, and given a value, returns an index j such that value is between array[j] and array[j+1]. array must be monotonic increasing. Returns 0 if value is less than or equal to the first element, and len(array)-1 if value is greater than or equal to the last element.

static find_nearest(a, a0)[source]#

Element in nd array a closest to the scalar value a0