Lightning Utilities

0.15.3 · active · verified Mon Apr 06

Lightning Utilities is a toolbox providing general Python utilities, reusable GitHub workflows, and shared GitHub actions for the broader Lightning ecosystem. It aims to offer common functionalities and development practices across Lightning-AI projects. The current version is 0.15.3, with frequent releases including patch and minor versions every few weeks.

Warnings

Install

Imports

Quickstart

This example demonstrates the core `apply_to_collection` utility, which recursively applies a function to all elements of a specified data type within a collection.

from lightning_utilities.core.apply_func import apply_to_collection

def double(x):
    return x * 2

data = [1, {'a': 2, 'b': [3, 4]}, (5, 6)]
result = apply_to_collection(data, int, double)
print(result)
# Expected output: [2, {'a': 4, 'b': [6, 8]}, (10, 12)]

view raw JSON →