oasislmf.pytools.gul.utils¶
This file contains general-purpose utilities used in gulpy.
Functions¶
|
Assuming array is a sorted array (increasing order), find the bin |
|
Append a value to the list populating a dictionary value. |
Module Contents¶
- oasislmf.pytools.gul.utils.binary_search(value, array, n)[source]¶
Assuming array is a sorted array (increasing order), find the bin where where array gets larger than value.
- Parameters:
- Returns:
- the first index of array where array is larger than value.
Returns -1 if this condition never occurs.
- Return type:
- oasislmf.pytools.gul.utils.append_to_dict_value(d, key, value, value_type)[source]¶
Append a value to the list populating a dictionary value. If the key is not present in the dictionary, populate the entry with a list with just the passed value. The dictionary d is modified in-place, thus it is not returned by the function. If d is a dictionary and d[key] is a list, this function appends value to the list. Example: if d = {0: [1, 2], 1: [3]}, then:
append_to_dict_entry(d, 0, 3, int)
will modify d to:
d = {0: [1, 2, 3], 1: [3]}
Designed to be used with numba.typed.Dict and numba.typed.List.
- Parameters:
d (numba.typed.Dict[*,numba.typedList[value_type]]) – dictionary to be modified, by appending value to the list in d[key].
key (same as d.key_type) – key of the element to modify.
value (value_type) – value to be appended to the list in d[key].
value_type (built-in Python or numba type) – value data type.