import dascore as dc
patch = dc.get_example_patch()
# Define a custom function that squares the data
def square_data(patch):
return patch.new(data=patch.data ** 2)
# Use pipe to apply the function
squared = patch.pipe(square_data)
# Can also chain with other methods
result = patch.pipe(square_data).mean(dim="time")pipe
Pipe the patch to a function.
This is primarily useful for maintaining a chain of patch calls for a function.
Parameters
| Parameter | Description |
|---|---|
| func |
The function to pipe the patch. It must take a patch instance as the first argument followed by any number of positional or keyword arguments, then return a patch. |
| *args | Positional arguments that get passed to func. |
| **kwargs | Keyword arguments passed to func. |