Misc Functions
Provide support for other library functionality.
This module support various other operations in this library, any function with no specific scope appears here.
The module contains the following functions:
choice(options,probs)
- choose a random element from a list given a probability distribution over the elements.window(iterable, size)
- Return a sliding window generator of size "size".get_dictionary_subkeys(target)
- Returns a list of all sub dictionary keys.chunkify(L, n)
- Yield successive n-sized chunks from L.
choice(options, probs)
Choose a single random variable from a list given a probability distribution
Parameters:
Name | Type | Description | Default |
---|---|---|---|
options |
list
|
The list of values from which a single random one should be chosen |
required |
probs |
float
|
Probability distribution. |
required |
Returns:
Name | Type | Description |
---|---|---|
element |
a random variable from list "options" with probability p in probas. |
Source code in src\LZGraphs\Utilities\misc.py
chunkify(L, n)
Yield successive n-sized chunks from L.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
L |
iterable
|
An iterable of elements to partition into n-sized chunks |
required |
Returns: generator: a generator that will return the next chunck each time its called until all of L is returned.
Source code in src\LZGraphs\Utilities\misc.py
get_dictionary_subkeys(target)
Returns a list of all sub dictionary keys.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target |
dict
|
a dictionary of dictionaries. |
required |
Returns: list: a list of all the keys contained in the sub dictionaries.
Source code in src\LZGraphs\Utilities\misc.py
window(iterable, size)
Return a sliding window generator of size "size".
Parameters:
Name | Type | Description | Default |
---|---|---|---|
iterable |
iterable
|
An iterable of elements |
required |
size |
int
|
The size of the sliding window. |
required |
Returns:
Name | Type | Description |
---|---|---|
zip |
a zip of all windows of size "size" |