pyiron / pyiron_workflow

Graph-and-node based workflows
BSD 3-Clause "New" or "Revised" License
10 stars 1 forks source link

[patch] More transformers #306

Closed liamhuber closed 1 month ago

liamhuber commented 1 month ago

Refactoring and adding transformers to support a @JNmpi -style for-loop that returns a dataframe. (I.e. contributes to the second half of #268)

New nodes are exposed on the creator (along with the existing list transformers) under the transformer namespace:

from pyiron_workflow import Workflow

wf = Workflow("transformer_demo")

channels = ["a", "b", "c"]

wf.my_dict = Workflow.create.transformer.inputs_to_dict(
    channels,  # Specify channel IO
    **{key: i**2 for i, key in enumerate(channels)}  # Input kwargs
)

wf.my_df = Workflow.create.transformer.inputs_to_dataframe(
    2,
    row_0=wf.my_dict,
    row_1=wf.my_dict,  # Whatever, just use the same thing twice for this demo
)

out = wf()

print(type(out.my_df__df))
>>> <class 'pandas.core.frame.DataFrame'>
print(len(out.my_df__df))
>>> 2
print(out.my_df__df.columns)
>>> Index(['a', 'b', 'c'], dtype='object')

Maybe these would be better under .create.std.transformer, but right now the standard library is still totally flat, so let's leave that to a future PR.

github-actions[bot] commented 1 month ago

Binder :point_left: Launch a binder notebook on branch _pyiron/pyiron_workflow/moretransformers

codacy-production[bot] commented 1 month ago

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
:white_check_mark: +0.15% (target: -1.00%) :white_check_mark: 97.33%
Coverage variation details | | Coverable lines | Covered lines | Coverage | | ------------- | ------------- | ------------- | ------------- | | Common ancestor commit (eaa2b51e6033e9b83ed49a2fd8e5b8fed029bd77) | 3716 | 3295 | 88.67% | | | Head commit (313243f1c8432435df411f04a37632ccd6b5cd80) | 3766 (+50) | 3345 (+50) | 88.82% (**+0.15%**) | **Coverage variation** is the difference between the coverage for the head and common ancestor commits of the pull request branch: ` - `
Diff coverage details | | Coverable lines | Covered lines | Diff coverage | | ------------- | ------------- | ------------- | ------------- | | Pull request (#306) | 75 | 73 | **97.33%** | **Diff coverage** is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: `/ * 100%`

See your quality gate settings    Change summary preferences

Codacy will stop sending the deprecated coverage status from June 5th, 2024. Learn more

coveralls commented 1 month ago

Pull Request Test Coverage Report for Build 8976769718

Details


Files with Coverage Reduction New Missed Lines %
transform.py 1 99.19%
create.py 9 90.91%
<!-- Total: 10 -->
Totals Coverage Status
Change from base Build 8976761176: 0.2%
Covered Lines: 3345
Relevant Lines: 3766

💛 - Coveralls