BatchList¶
redcat.BatchList ¶
Bases: BaseBatch[list[T]]
Implement a batch object to easily manipulate a list of examples.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
list[T]
|
Specifies the list of examples. |
required |
Raises:
Type | Description |
---|---|
TypeError
|
if the input is not a list. |
Example usage:
>>> from redcat import BatchList
>>> batch = BatchList([1, 2, 3])
>>> batch
BatchList(data=[1, 2, 3])
redcat.BatchList.apply ¶
apply(fn: Callable[[T], T]) -> Self
Apply a function to transform the element in the list of the current batch.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn
|
Callable[[T], T]
|
Specifies the function to be applied to the element in the list. It is the responsibility of the user to verify the function applies a valid transformation of the data. |
required |
Returns:
Type | Description |
---|---|
Self
|
The transformed batch. |
Example usage:
>>> from redcat import BatchList
>>> batch = BatchList([1, 2, 3])
>>> batch.apply(lambda val: val + 2)
BatchList(data=[3, 4, 5])
redcat.BatchList.apply_ ¶
apply_(fn: Callable[[T], T]) -> None
Apply a function to transform the element in the list of the current batch.
In-place version of apply
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn
|
Callable[[T], T]
|
Specifies the function to be applied to the element in the list. It is the responsibility of the user to verify the function applies a valid transformation of the data. |
required |
Example usage:
>>> from redcat import BatchList
>>> batch = BatchList([1, 2, 3])
>>> batch.apply_(lambda val: val + 2)
>>> batch
BatchList(data=[3, 4, 5])