tidy3d.plugins.autograd.utilities.chain#
- class chain[source]#
- Bases: - Chain multiple functions together to apply them sequentially to an array. - Parameters:
- funcs (Union[Callable, Iterable[Callable]]) β A variable number of functions or a single iterable of functions to be chained together. 
- Returns:
- A function that takes an array and applies the chained functions to it sequentially. 
- Return type:
- Callable 
 - Examples - >>> import numpy as np >>> from tidy3d.plugins.autograd.utilities import chain >>> def add_one(x): ... return x + 1 >>> def square(x): ... return x ** 2 >>> chained_func = chain(add_one, square) >>> array = np.array([1, 2, 3]) >>> chained_func(array) array([ 4, 9, 16]) - >>> # Using a list of functions >>> funcs = [add_one, square] >>> chained_func = chain(funcs) >>> chained_func(array) array([ 4, 9, 16]) - Inherited Common Usage