Skip to content

Merge new stack-like function with stack? #83

@light-matters

Description

@light-matters

In addressing #67 and the desire to reduce duplication in compositions like prepare_atoms, i.e. killing the need to make intermediary kws and functions, we now have cascade:

def cascade(*fs, **kws):
    """
    Similarly to `stack`, a convenience that combines an arbitrary chain of functions with an arbitrary selection of associated keywords.

    Currently, `kws` are passed to the associated functions by prefixing, e.g. `cascade(MOT, molasses,  MOT_duration=1.0)` creates a `stack` of `MOT` and `molasses`, with `duration=1.0` passed into the `MOT` function before evaluation.

    The motivation for this feature is that different experimental contexts should be built modularly, but, at final composition, the user often just wants a single point of contact to add/change nested variables.
    """

It is similar enough to stack that it might be possible to combine the two, but we should consider the pros and cons, e.g. would it be too confusing for the user? Basically it could work as an extension, where kws that match the pattern for cascade could be cascaded and those that don't could just be added to every function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions