pyiron / pyiron_workflow

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

[minor] Introduce for-loop #309

Closed liamhuber closed 1 month ago

liamhuber commented 1 month ago
from pyiron_workflow import Workflow

@Workflow.wrap.as_function_node("together")
def Three(a: int, b: int, c: int, d: int, e: str = "foobar"):
    return (a, b, c, d, e),

for_instance = Workflow.create.for_node(
    Three,
    iter_on=("a", "b"),
    zip_on=("c", "d"),
    a=[1, 2], 
    b=[3, 4, 5], 
    c=[6, 7], 
    d=[7, 8, 9], 
    e="e"
)
out = for_instance()
out.df

You are locked-in to iterating on those variables and not the others, but can freely re-run with different lengths for the input. And the whole thing is (un)pickleable, as usual.

TODO:

The old Workflow.create.meta.for_loop is gone in favour of Workflow.create.for_node.

github-actions[bot] commented 1 month ago

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

codacy-production[bot] commented 1 month ago

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
:white_check_mark: +0.39% (target: -1.00%) :white_check_mark: 100.00%
Coverage variation details | | Coverable lines | Covered lines | Coverage | | ------------- | ------------- | ------------- | ------------- | | Common ancestor commit (c0228221edc9c181c7f8fd3d49bff8d751756470) | 3797 | 3378 | 88.96% | | | Head commit (c42555396c5c917ebc12c760e83fdac3de38f19b) | 3925 (+128) | 3507 (+129) | 89.35% (**+0.39%**) | **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 (#309) | 149 | 149 | **100.00%** | **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

review-notebook-app[bot] commented 1 month ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

coveralls commented 1 month ago

Pull Request Test Coverage Report for Build 8976890053

Details


Files with Coverage Reduction New Missed Lines %
create.py 8 93.55%
channels.py 15 94.25%
<!-- Total: 23 -->
Totals Coverage Status
Change from base Build 8976848513: 0.4%
Covered Lines: 3507
Relevant Lines: 3925

💛 - Coveralls