booldog.utils.misc
Attributes
Classes
Create a collection of name/value pairs. |
Functions
Return numpy array of v, given array, int/float, list, tuple |
|
|
Parameter argument to numpy array |
|
Checks if path is writeable. If not, attempts to provide reason, and raises |
Get version of booldog package |
Module Contents
- booldog.utils.misc.logger
- class booldog.utils.misc.ExtendedEnum(*args, **kwds)
Bases:
enum.EnumCreate a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- classmethod values()
- booldog.utils.misc.ensure_ndarray(v)
Return numpy array of v, given array, int/float, list, tuple
- booldog.utils.misc.parameter_to_array(parameter, graph_keys)
Parameter argument to numpy array
- Parameters:
parameter (array, int, float or dict) –
- if array:
make sure length is n
- if int or float:
return an array of length n with value
- if dict:
returns an array of length n with values set according to
keys (nodes indexed by graph_keys), and the rest set to ‘default’ key
graph_keys (dict)
- Returns:
parameter_array – array of length n
- Return type:
numpy array
- booldog.utils.misc.file_writable(path)
Checks if path is writeable. If not, attempts to provide reason, and raises an Exception.
- Parameters:
path (str or Path) – Path to file to check for writability. If the file does not exist, the function will check if it can be created.
- Return type:
None
- booldog.utils.misc.get_pkg_version()
Get version of booldog package
- Returns:
version – Version of booldog package
- Return type:
str