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