8.4.13. 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, attribute=None, attributes=None, args=(), kwargs=None)[source]
Bases:
SerializableBaseGeneric object to pass info (command) and data (attribute) between thread or objects using signals
- Parameters:
command (
str) – The command to be analysed for further actionattribute (
any type) – the attribute related to the command. The actual type and value depend on the command and the situationattributes (
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
- args
- Type:
some variables in a list
- kwargs
- Type:
some variables in a dict
Methods
deserialize(bytes_str)serialize(obj)
- 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 :type string:
(str):param string: :type string:(str):type Nfirst:(int):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 :type data: :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 dictionary :type dict_tmp:
(dict) the dictionarytobe tested:param dict_tmp: :type dict_tmp:(dict) the dictionarytobe tested:type key:(str) a key stringtolook for in dict_tmp:param key: :type key:(str) a key stringtolook for in dict_tmp:type value:(object) any python object: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
- Parameters:
dicts (
(list) listofdictionnaries)key (
(str) specific keytolook for in each dict)value (
valuetomatch)
- Returns:
dict
- Return type:
if found otherwise returns None
- pymodaq_utils.utils.find_dicts_in_list_from_key_val(dicts, key, value)[source]
lookup within a list of dicts. Look for the dicts within the list which have the correct key, value pair
- Parameters:
dicts (
(list) listofdictionnaries)key (
(str) specific keytolook for in each dict)value (
valuetomatch)
- Returns:
dict
- Return type:
if found otherwise returns None
- pymodaq_utils.utils.find_keys_from_val(dict_tmp, val)[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, attr_name, attr_value, 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:
- pymodaq_utils.utils.getLineInfo()[source]
get information about where the Exception has been triggered
- pymodaq_utils.utils.get_entrypoints(group='pymodaq.plugins')[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- Return type:
- 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 :type string: :param string:
- pymodaq_utils.utils.rint(x)[source]
almost same as numpy rint function but return an integer :type x:
(floatorinteger):param x: :type x:(floatorinteger)- Return type:
nearest integer
- pymodaq_utils.utils.zeros_aligned(n, align, dtype=<class 'numpy.uint32'>)[source]
Get aligned memory array wih alignment align. :type n:
(int) length in dtype bytesofmemory:param n: :type n:(int) length in dtype bytesofmemory:type align:(int) memory alignment:param align: :type align:(int) memory alignment:type dtype:(numpy.dtype) typeofthe stored memory elements:param dtype: :type dtype:(numpy.dtype) typeofthe stored memory elements