smpl.util
Simplified general utilities.
|
Return the element in |
|
Returns the index of the element in |
|
Returns dict[key] if this exists else default. |
|
Checks if the key is in the dict and not None. |
|
Concats string |
|
Checks if the key is in the dict and not None and True. |
Functions
- smpl.util.find_nearest(array, value)[source]
Return the element in
arrayclosest tovalueExamples
>>> find_nearest([1,7,6,2] , 1.9) 2
- smpl.util.find_nearest_index(array, value)[source]
Returns the index of the element in
arrayclosest tovalueExamples
>>> find_nearest_index([1,7,6,2] , 1.9) 3
- smpl.util.get(key, ddict, default)[source]
Returns dict[key] if this exists else default.
Examples
>>> d = {'a' : 1 , 'b' : 2 , 'c' : 3} >>> get('a',d,5) 1 >>> get('x',d,5) 5