erlab.utils.misc¶
Utilities that don’t fit in any other category.
Functions
|
Emit a warning at the user level by inspecting the stack trace. |
Check if the code is running in an interactive environment. |
|
|
Check if the given object is a sequence of elements of the specified type. |
|
Open a directory in the system's file manager. |
Classes
|
Lazily import a module when an attribute is accessed. |
- class erlab.utils.misc.LazyImport(module_name, err_msg=None)[source]¶
Bases:
objectLazily import a module when an attribute is accessed.
Used to delay the import of a module until it is actually needed.
- Parameters:
Examples
>>> np = LazyImport("numpy") >>> np.array([1, 2, 3]) array([1, 2, 3])
- erlab.utils.misc.emit_user_level_warning(message, category=None)[source]¶
Emit a warning at the user level by inspecting the stack trace.
- erlab.utils.misc.is_interactive()[source]¶
Check if the code is running in an interactive environment.
- erlab.utils.misc.is_sequence_of(val, element_type)[source]¶
Check if the given object is a sequence of elements of the specified type.
- Parameters:
- Returns:
bool–Trueifvalis a sequence and all elements in the sequence are of typeelement_type,Falseotherwise.- Return type:
Examples
>>> is_sequence_of([1, 2, 3], int) True
>>> is_sequence_of([1, 2, "3"], int) False