7.4.12. pymodaq_utils.utils module
- class pymodaq_utils.utils.JsonConverter[source]
Bases:
objectMethods
istrusted
json2object
object2json
trusted_types
- class pymodaq_utils.utils.PlotColors(colors=[[255, 255, 255], [255, 0, 0], [0, 255, 0], [0, 0, 255], [14, 207, 189], [207, 14, 166], [207, 204, 14]])[source]
Bases:
objectMethods
check_color
check_colors
copy
remove
- class pymodaq_utils.utils.ThreadCommand(command: str, attribute=None, attributes=None)[source]
Bases:
objectGeneric object to pass info (command) and data (attribute) between thread or objects using signals
- Parameters:
command (str) – The command to be analysed for further action
attribute (any type) – the attribute related to the command. The actual type and value depend on the command and the situation
attributes (deprecated, attribute should be used instead) –
- attribute
the attribute related to the command. The actual type and value depend on the command and the situation
- Type:
any type
- pymodaq_utils.utils.caller_name(skip=2)[source]
Get a name of a caller in the format module.class.method
skip specifies how many levels of stack to skip while getting caller name. skip=1 means “who calls me”, skip=2 “who calls my caller” etc.
An empty string is returned if skipped levels exceed stack height
- pymodaq_utils.utils.capitalize(string, Nfirst=1)[source]
Returns same string but with first Nfirst letters upper :param string: :type string: (str) :param Nfirst: :type Nfirst: (int)
- Return type:
- pymodaq_utils.utils.count_lines(ini_path, count=0, filters=['lextab', 'yacctab', 'pycache', 'pyc'])[source]
- pymodaq_utils.utils.ensure_ndarray(data)[source]
Make sure data is returned as a numpy array :param data:
- Return type:
ndarray
- pymodaq_utils.utils.find_dict_if_matched_key_val(dict_tmp, key, value)[source]
check if a key/value pair match in a given dictionnary :param dict_tmp: :type dict_tmp: (dict) the dictionnary to be tested :param key: :type key: (str) a key string to look for in dict_tmp :param value: :type value: (object) any python object
- Returns:
bool
- Return type:
True if the key/value pair has been found in dict_tmp
- pymodaq_utils.utils.find_dict_in_list_from_key_val(dicts, key, value, return_index=False)[source]
lookup within a list of dicts. Look for the dict within the list which has the correct key, value pair
- pymodaq_utils.utils.find_keys_from_val(dict_tmp: dict, val: object)[source]
Returns the keys from a dict if its value is matching val
- pymodaq_utils.utils.find_object_if_matched_attr_name_val(obj, attr_name, attr_value)[source]
check if an attribute key/value pair match in a given object
- pymodaq_utils.utils.find_objects_in_list_from_attr_name_val(objects: List[object], attr_name: str, attr_value: object, return_first=True)[source]
lookup within a list of objects. Look for the objects within the list which has the correct attribute name, value pair
- Parameters:
- Returns:
list of tuple(object, int)
- Return type:
object and index or list of object and indexes
- pymodaq_utils.utils.getLineInfo()[source]
get information about where the Exception has been triggered
- pymodaq_utils.utils.get_entrypoints(group='pymodaq.plugins') List[EntryPoint][source]
Get the list of modules defined from a group entry point
Because of evolution in the package, one or another of the forms below may be deprecated. We start from the newer way down to the older
- Parameters:
group (str) – the name of the group
- pymodaq_utils.utils.get_new_file_name(base_path=PosixPath('C:\\Data'), base_name='tttr_data')[source]
- pymodaq_utils.utils.get_version(package_name='pymodaq')[source]
Obtain the package version using the importlib metadata module
- pymodaq_utils.utils.recursive_find_expr_in_files(ini_path, exp='make_enum', paths=[], filters=['.git', '.idea', '__pycache__', 'build', 'egg', 'documentation', '.tox'], replace=False, replace_str='')[source]
- pymodaq_utils.utils.recursive_find_files(ini_path, exp='make_enum', paths=[], filters=['build'])[source]
- pymodaq_utils.utils.remove_spaces(string)[source]
return a string without any white spaces in it :param string:
- pymodaq_utils.utils.rint(x)[source]
almost same as numpy rint function but return an integer :param x: :type x: (float or integer)
- Return type:
nearest integer
- pymodaq_utils.utils.zeros_aligned(n, align, dtype=<class 'numpy.uint32'>)[source]
Get aligned memory array wih alignment align. :param n: :type n: (int) length in dtype bytes of memory :param align: :type align: (int) memory alignment :param dtype: :type dtype: (numpy.dtype) type of the stored memory elements