General Utilities

General Utilities#

The immlib library includes a large number of utility functions. Although many of these functions are tangential to immlib’s core workflow components, they are nonetheless intended to assist scientists in writing scientific libraries and APIs. For example, the immlib.numapi decorator allows one to easily write functions that accept either PyTorch tensors or NumPy arrays. While such a function isn’t necessary for supporting immlib’s workflow tools, it is nonetheless a useful function for numerical APIs that wish to work seamlessly with either library.

The utilities provided by immlib fall into several categories:

  • Numerical Utilities. These utilities include tools for transforming between NumPy arrays and PyTorch tensors and tools for querying them.

  • Utilities for Physical Units. immlib uses the pint library to represent physical units. Quantities with units are generally handled seamlessly my immlib’s functions, including the numerical utilities, but the library provides various helper functions as well.

  • Functional Programming Utilities. Although immlib generally uses a functional and immutable style, there are a number of helper functions included that make certain functional operations that are not terribly common in Python much easier.

  • String Utilities. A handful of string comparison functions that respect string encodings are included in the library.

  • Other Utilities. A few miscellaneous utilities that don’t cleanly fall into any of the other categories are included in this section.