smpl.util¶
Simplified general utilities.
Submodules¶
Package Contents¶
Functions¶
|
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. |
- 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=None)[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
- smpl.util.has(key, ddict)[source]¶
Checks if the key is in the dict and not None.
Examples¶
>>> d = {'a' : 1 , 'b' : 2 , 'c' : 3} >>> has('a',d) True >>> has('x',d) False