Skip to content

Add swap_node and swap_param to replace a parameter (#22) - #89

Merged
joergbrech merged 1 commit into
mainfrom
22-allow-replacing-a-parameter-v2
Nov 5, 2026
Merged

joergbrech merged 1 commit into
mainfrom
22-allow-replacing-a-parameter-v2

Conversation

@joergbrech

Copy link
Copy Markdown
Collaborator

Fixes #22. Replaces the stale PR #53.

  • dag.hpp: swap_node(old, new) moves every consumer of old to new, keeping argument positions,
    including duplicate slots. It checks for cycles before changing anything, so a failure leaves the
    graph untouched. Null nodes and compute nodes (whose output order matters) throw
    std::invalid_argument. Swapping a node with itself does nothing. Moved children are invalidated.
  • core.hpp: swap_param(param<T,S>, param<T,S>) is a typed wrapper that rejects mismatched types at
    compile time.
  • Tests: 14 new tests, 6 at the DAG level and 8 using eval. They cover duplicate arguments, cycles,
    dead children, an old param that goes out of scope, a multi-output compute node, and clone.
  • Docs and changelog: a "Replacing a parameter" section in docs/usage.rst and an entry in Changelog.md

@joergbrech
joergbrech merged commit 15cd795 into main Nov 5, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow replacing a parameter

1 participant