lsst.utils¶
The lsst.utils module provides common code for tests, interfacing between C++ and Python, and debugging.
Changes¶
- lsst-utils v29.1.1 (2025-06-19)
- lsst-utils v29.1.0 (2025-05-22)
- lsst-utils v29.0.0 (2025-03-24)
- lsst-utils v28.0.0 (2024-11-19)
- lsst-utils 27.0.0 (2024-05-28)
- lsst-utils v26.0.0 (2023-09-22)
- lsst-utils v25.0.0 (2023-02-17)
- lsst-utils v24.0.0 (2022-08-26)
- lsst-utils v23.0.0 (2021-09-27)
- lsst-utils v22.0 (2021-07-09)
- lsst-utils v21.0 (2020-12-08)
Contributing¶
lsst.utils is developed at https://github.com/lsst/utils.
You can find Jira issues for this module under the utils component.
Python API reference¶
lsst.utils Package¶
Functions¶
| 
 | Re-open the decorated class, adding any new definitions into the original. | 
| 
 | Deprecate a pybind11-wrapped C++ interface function, method or class. | 
| 
 | Import a python object given an importable string and return it. | 
| 
 | Import a python type given an importable string and return it. | 
| 
 | Find the file system location of the EUPS package. | 
| 
 | Add the decorated function to the given class as a method. | 
| 
 | Extend existing documentation for a method that exists in another class and extend it with any additional documentation defined. | 
| 
 | Suppress warnings generated by  | 
Classes¶
| 
 | A metaclass for abstract base classes that tie together wrapped C++ template types. | 
Class Inheritance Diagram¶
lsst.utils.tests Module¶
Functions¶
| 
 | Highly-configurable floating point comparisons for scalars and arrays. | 
| 
 | Assert that lhs == rhs (both numeric types, whether scalar or array). | 
| 
 | Fail a test if the given floating point values are equal to within the given tolerances. | 
| 
 | Class decorator for generating unit tests. | 
| 
 | Enter the debugger when there's an uncaught exception. | 
| 
 | Return a path suitable for a temporary file and try to delete the file on success. | 
| 
 | Initialize the memory tester and file descriptor leak tester. | 
| 
 | Iterate over supplied settings to create subtests automatically. | 
| Context manager that creates and destroys a temporary directory. | 
Classes¶
| 
 | Test that executables can be run and return good status. | 
| 
 | Test that the named packages can be imported and all files within that package. | 
| 
 | Check for resource leaks. | 
| 
 | Subclass of unittest.TestCase that adds some custom assertions for convenience. | 
Class Inheritance Diagram¶
lsst.utils.logging Module¶
Functions¶
| 
 | Get a logger compatible with LSST usage. | 
| 
 | Get a logger with the appropriate TRACE name. | 
| 
 | Adjust logging level to display messages with the trace number being less than or equal to the provided value. | 
Classes¶
| 
 | A special logging adapter to provide log features for LSST code. | 
| 
 | Issue log messages if a time threshold has elapsed. | 
Class Inheritance Diagram¶
lsst.utils.iteration Module¶
Functions¶
| 
 | Return smaller chunks of an iterable. | 
| Ensure that the input is iterable. | |
| 
 | Split a string or bytes by separator returning a generator. | 
| 
 | Convert a list of integers or strings into a compact string representation by merging consecutive values or sequences. | 
lsst.utils.classes Module¶
Functions¶
| 
 | Decorate a method to cache the result. | 
| 
 | Decorate a class to simulate a simple form of immutability. | 
Classes¶
| Metaclass to convert a class to a Singleton. | 
Class Inheritance Diagram¶
lsst.utils.introspection Module¶
Functions¶
| 
 | Find the stacklevel for outside of the given module. | 
| 
 | Get the name of the caller method. | 
| 
 | Given the type name or a type, return the python type. | 
| 
 | Return full type name of the supplied entity. | 
| 
 | Given the type name or a type, instantiate an object of that type. | 
| Count the number of existing objects, by type. | |
| 
 | Find the chain(s) of references that make(s) objects of a class reachable. | 
lsst.utils.timer Module¶
Functions¶
| 
 | Parse the metadata entries from  | 
| 
 | Log timer information to  | 
| 
 | Profile the enclosed code block and save the result to a file. | 
| 
 | Measure duration of a method. | 
| 
 | Time the enclosed block and issue a log message. | 
lsst.utils.packages Module¶
Functions¶
| Get the versions for all Python distributions that are installed. | |
| Get products and their versions from the conda environment. | |
| 
 | Get products and their versions from the environment. | 
| Get imported python packages and their versions. | |
| 
 | Determine the version of a python module. | 
Classes¶
| A table of packages and their versions. | 
Class Inheritance Diagram¶
lsst.utils.usage Module¶
Functions¶
| Report current memory usage. | |
| Report peak memory usage. | 
lsst.utils.threads Module¶
Functions¶
| Do whatever is necessary to try to prevent implicit threading. | |
| 
 | Set common threading environment variables to the given value. |