Skip to content

Fixed the get_var func #1441

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

prajwalun
Copy link

@prajwalun prajwalun commented Jun 5, 2025

Description

This PR fixes and improves the get_var_by_name utility function:

  • Removes the unused ids parameter.
  • Adds a new include_inner_graphs flag (default: False) to control whether variables from inner graphs (e.g., inside Scan, FunctionGraph, etc.) are included in the search.
  • Updates the docstring for clarity and accurate parameter documentation.
  • Adds a dedicated test to verify that inner graph variables are only returned when include_inner_graphs=True.

This behavior aligns with issue #1440 and ensures graph traversal behaves in a more predictable and scoped manner by default.

Related Issue

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

📚 Documentation preview 📚: https://pytensor--1441.org.readthedocs.build/en/1441/

Copy link
Member

@ricardoV94 ricardoV94 left a comment

Choose a reason for hiding this comment

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

Looks great

@ricardoV94
Copy link
Member

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.

Tweak get_var_by_name
2 participants