qudi.util.helpers
Functions
|
Parse a list literal (with or without square brackets) given as a string containing comma-separated int or float values to a Python list. |
|
Check if a value is in a given range an return closest possible value in range. |
|
Check all available complex representations |
|
Check if passed object is a complex type |
|
Check all available float representations |
|
Check if passed object is a float type |
|
Check all available integer representations |
|
Check if passed object is an integer type |
|
Check whether passed value is a number |
|
Check whether passed object is a number type |
|
Check all available string representations |
|
Check if passed object is a string type |
|
Has the same signature as pkgutil.iter_modules() but extends the functionality by walking through the entire directory tree and concatenating the return values of pkgutil.iter_modules() for each directory. |
|
Sort an iterable of strings in an intuitive, natural way (human/natural sort). |
|
Parse a string into either int, float or complex (in that order) |
- qudi.util.helpers.csv_2_list(csv_string: str, str_2_val: Callable[[str], Any] | None = None) List[Any][source]
Parse a list literal (with or without square brackets) given as a string containing comma-separated int or float values to a Python list.
Blanks before and after commas are handled.
- Parameters:
- csv_stringstr
Scalar number literals as strings separated by a single comma and any number of blanks. Brackets are ignored. Example: ‘[1e-6,2.5e6, 42]’ or ‘1e-6, 2e-6, 42’.
- str_2_valfunction, optional
Function to use for casting substrings into single values.
- Returns:
- list
List of float values. If str_2_val is provided, type is invoked by this function.
- qudi.util.helpers.in_range(value: int | float, lower_limit: int | float, upper_limit: int | float) Tuple[bool, int | float][source]
Check if a value is in a given range an return closest possible value in range. Also check the range. Return value is clipped to range.
- qudi.util.helpers.is_complex(test_value: Any) bool[source]
Check all available complex representations
- qudi.util.helpers.is_complex_type(test_obj: Type) bool[source]
Check if passed object is a complex type
- qudi.util.helpers.is_float_type(test_obj: Type) bool[source]
Check if passed object is a float type
- qudi.util.helpers.is_integer(test_value: Any) bool[source]
Check all available integer representations
- qudi.util.helpers.is_integer_type(test_obj: Type) bool[source]
Check if passed object is an integer type
- qudi.util.helpers.is_number_type(test_obj: Type) bool[source]
Check whether passed object is a number type
- qudi.util.helpers.is_string(test_value: Any) bool[source]
Check all available string representations
- qudi.util.helpers.is_string_type(test_obj: Type) bool[source]
Check if passed object is a string type
- qudi.util.helpers.iter_modules_recursive(paths: str | Iterable[str], prefix: str | None = '') List[ModuleInfo][source]
Has the same signature as pkgutil.iter_modules() but extends the functionality by walking through the entire directory tree and concatenating the return values of pkgutil.iter_modules() for each directory.
Additional modifications include: - Directories starting with “_” or “.” are ignored (including their sub-directories). - Python modules starting with a double-underscore (“__”) are excluded from the result.
- Parameters:
- pathsiterable
Iterable of root directories to start the search for modules.
- prefixstr, optional
Prefix to prepend to all module names.
- Returns:
- iterable
Concatenated return values of pkgutil.iter_modules() for all directories in the tree.
- qudi.util.helpers.natural_sort(iterable: Iterable[Any]) List[Any][source]
Sort an iterable of strings in an intuitive, natural way (human/natural sort). This is useful for sorting alphanumeric strings that contain integers.
- Parameters:
- iterablelist of str
Iterable with string items to sort.
- Returns:
- list
Sorted list of strings.