Skip to content

Conversation

@mscroggs
Copy link
Collaborator

@mscroggs mscroggs commented Aug 15, 2025

@mscroggs mscroggs requested a review from willGraham01 August 15, 2025 10:56
Comment on lines 8 to 22
def get_included_excluded_successors(
graph: Graph, nodes: dict[str, Node], node: str
) -> tuple[list[str], list[str]]:
"""
Get list of successors that are included in and excluded from nodes dictionary.
Args:
graph: The graph
nodes: A dictionary of nodes, indexed by label
node: The node to check the successors of
Returns:
Lists of included and excluded nodes
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def get_included_excluded_successors(
graph: Graph, nodes: dict[str, Node], node: str
) -> tuple[list[str], list[str]]:
"""
Get list of successors that are included in and excluded from nodes dictionary.
Args:
graph: The graph
nodes: A dictionary of nodes, indexed by label
node: The node to check the successors of
Returns:
Lists of included and excluded nodes
"""
def get_included_excluded_successors(
graph: Graph, nodes_to_split: dict[str, Node], successors_of: str
) -> tuple[list[str], list[str]]:
"""
Split nodes into two groups; those that are successors or another node, and those that are not.
Args:
graph: The graph
nodes_to_split: A dictionary of nodes, indexed by label
successor_of: The node to check the successors of
Returns:
Lists of included and excluded nodes
"""

It took me a few tries to figure out what was going on here, until I saw the variable names and what was going on in the function. I've suggested a change to the docstring and variable names which I think makes it a bit clearer what's going on? (You'll have to change the variable names in the function though, sorry):

  • nodes $\rightarrow$ nodes_to_split
  • node $\rightarrow$ successors_of

Copy link
Collaborator

Choose a reason for hiding this comment

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

(Will also add here that return types could also be tuple of tupless)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I updated the docstring: it splits the successors of the node into nodes in the list and not in the list (instead of splitting the nodes into successors and non-successors). The had to make it less long as ruff got annoyed

return included, excluded


def removable_nodes(graph: Graph, nodes: dict[str, Node]) -> list[str]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

More a comment here for my own understanding, but both removable_nodes and get_incluced_excluded_nodes are only be needed if we want to retain some numpyro-independent implementation of do right (in case we go back to the backend-agnostic stuff)? If we are only wanting to use numpryo, we could just do this for the time being (assuming the other caveats).

Would be an interesting test case to compare our do and this one, regardless.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've opened #91 to remind me that this is a test we want

@mscroggs mscroggs merged commit 0577ae1 into main Aug 18, 2025
5 checks passed
@mscroggs mscroggs deleted the mscroggs/do-test branch August 18, 2025 13:17
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.

Improve unit testing of do()

3 participants