Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix recursion error when using multiple Pipeline.set_param_series #150

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/sciline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def _find_all_paths(
return []
paths = []
for node in dependencies[start]:
if start == node:
continue
for path in _find_all_paths(dependencies, node, end):
paths.append([start] + path)
return paths
Expand Down
20 changes: 20 additions & 0 deletions tests/pipeline_with_param_table_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,3 +719,23 @@ def to_str(x: int) -> str:
pl = sl.Pipeline((to_str,))
pl.set_param_series(int, ints)
assert pl.compute(sl.Series[int, str]) == sl.Series(int, {1: '1', 2: '2', 3: '3'})


def test_multiple_param_series_can_be_broadcast() -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you also try putting the beam center finder provider back into the loki direct beam workflow with multiple files to see if it fixes it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can also try it if you prefer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not try, no. Go ahead, since you know which pieces to touch!

ints = [1, 2, 3]
floats = [1.0, 2.0]

def to_str(x: int, y: float) -> str:
return str(x) + str(y)

pl = sl.Pipeline((to_str,))
pl.set_param_series(int, ints)
pl.set_param_series(float, floats)
assert pl.compute(sl.Series[int, sl.Series[float, str]]) == sl.Series(
int,
{
1: sl.Series(float, {1.0: '11.0', 2.0: '12.0'}),
2: sl.Series(float, {1.0: '21.0', 2.0: '22.0'}),
3: sl.Series(float, {1.0: '31.0', 2.0: '32.0'}),
},
)
Loading