-
Notifications
You must be signed in to change notification settings - Fork 0
Pipelining
This sub-module contains classes designed to allow users to construct a pipeline from user-defined functions.
This class allows the user to construct a multiple-data pipeline from user-defined functions.
from jutl.pipelining import DataPipeline
# Example user-defined functions
def add_ten(num):
return num + 10
def subtract_five(num):
return num - 5
pipeline = DataPipeline(add_ten, subtract_five)
result = pipeline(20, 30, 50, 80, 120) # result = [25, 35, 55, 85, 125]
Argument | Data type | Default | Description |
---|---|---|---|
*functions |
objects | n Functions to construct the pipeline from | |
name |
string | None |
Optional identifier to be given to pipeline |
This is a series of function objects passed directly to the pipeline class upon object instantiation. Passing multiple of the same object is permitted.
Note You must ensure the passed functions' returns are compatible with each others' arguments.
Argument | Required | Accepted values |
---|---|---|
*functions |
❌ | Any number of function objects |
name |
❌ | Any string |
When called with parentheses and data passed, the pipeline object will compute the result of the data after passing through all functional elements of the pipeline. If called without parentheses, the pipeline will output its representation as its name with the number of functions in its pipeline.
This object computes and returns the result of the inputted data series having passed through the functional components, thus its only side-effect is what it outputs if it is called with no parentheses.
This class allows the user to construct a single-data pipeline from user-defined functions.
from jutl.pipelining import InstructionPipeline
# Example user-defined functions
def add_ten(num):
return num + 10
def subtract_five(num):
return num - 5
pipeline = InstructionPipeline(add_ten, subtract_five)
result = pipeline(20) # result = 25
Argument | Data type | Default | Description |
---|---|---|---|
*functions |
objects | n Functions to construct the pipeline from | |
name |
string | None |
Optional identifier to be given to pipeline |
This is a series of function objects passed directly to the pipeline class upon object instantiation. Passing multiple of the same object is permitted.
Note You must ensure the passed functions' returns are compatible with each others' arguments.
Argument | Required | Accepted values |
---|---|---|
*functions |
❌ | Any number of function objects |
name |
❌ | Any string |
When called with parentheses and data passed, the pipeline object will compute the result of the data after passing through all functional elements of the pipeline. If called without parentheses, the pipeline will output its representation as its name with the number of functions in its pipeline.
This object computes and returns the result of the input data having passed through the functional components, thus its only side-effect is what it outputs if it is called with no parentheses.
Created, and maintained by Jordan Welsman @ BU.
jutils
, jutl
Copyright (c) 2022-2023, Jordan Welsman.
All rights reserved.