-
Notifications
You must be signed in to change notification settings - Fork 2
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
Mapping non-source nodes #174
Comments
I am not sure this is something that Cyclebane should do: Conceptually, |
Maybe |
How would that work with multiple mapped values? Here is a more complete example of what we would need in reflectometry: import sciline as sl
def get_sample_angle(filename: str) -> float:
return 0.1 * len(filename)
def load(filename: str) -> int:
return len(filename)
def calc(data: int, angle: float) -> tuple[int, float]:
return data, angle
pl = sl.Pipeline([get_sample_angle, load, calc])
pl = pl.map({str: ['aa', 'bbb'], float: [10.0, 20.0]})
r = sl.compute_mapped(pl, tuple[int, float]) With your suggestion pl = pl[float:].map({str: ['aa', 'bbb'], float: [10.0, 20.0]}) I get
|
Yes, this is not implemented yet, I was a hypothetical syntax. |
You would need to use
Have you considered other solutions, such as removing the provider, not inserting the provider in the first place, or moving the sample-angle-load into a small helper pipeline that can be added via |
Not in detail. If in the long run, we want to map over filenames and sample angles in this way, then we would of course adapt the pipeline. But for a quick test, that would be difficult. And this includes removing a parameter after the fact. |
It can be useful to map over nodes that have inputs but Sciline / Cyclebane do not allow this. For example, in ESSreflectometry, we want to map over filenames and sample angles. However, the sample angle is by default read from a file. So its provider has inputs and Sciline refuses to map over it.
Here is a simplified example:
This fails with
ValueError: Mapped node '<class 'float'>' is not a source node
.It can be circumvented using
but this is not great.
Mapping nodes corresponds to assigning values to them. So it is analogous to setting a parameter value. And since this is allowed for non-source nodes, mapping should also be allowed.
The text was updated successfully, but these errors were encountered: