Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to add a user-facing pm.print_value() helper to wrap pytensor.printing.Print for debug-printing variable values during model evaluation/sampling, as proposed in #6841.
Changes:
- Adds a
print_value()helper intended to wrap PyTensor’sPrintop. - Exposes the helper from the
pymctop-level namespace aspm.print_value. - Adds tests validating pass-through behavior and naming behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
printing.py |
Adds a print_value() helper, but currently added at repo root rather than the pymc package module. |
pymc/__init__.py |
Attempts to expose print_value on the pymc namespace (currently will import-error due to module placement). |
tests/test_print_value.py |
Adds tests for print_value behavior and top-level accessibility. |
__init__.py |
Adds a repo-root __init__.py that makes the repo root a package (unexpected/undesirable). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # pymc/printing.py | ||
|
|
||
| """Helper utilities for debugging PyMC models.""" | ||
|
|
||
| from pytensor.printing import Print | ||
|
|
||
| __all__ = ["print_value"] |
There was a problem hiding this comment.
This file is added at the repository root as printing.py, but the package module that users/tests import is pymc/printing.py (which already exists). As a result, from pymc.printing import print_value will not find this function, and the helper won’t be available as pm.print_value. Move this helper into pymc/printing.py (and export it via that module’s __all__) and remove the root-level printing.py to avoid confusion/shadowing.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
Adds a
pm.print_value()helper function as proposed in #6841.Previously, users had to manually initialize
pytensor.printing.Printwhich is an unusual API. This helper wraps that op with a clean,
discoverable interface.
Usage
Changes
pymc/printing.py— newprint_value()helperpymc/__init__.py— expose aspm.print_valuetests/test_print_value.py— tests for pass-through and namingCloses #6841
The print_value helper is the clearest, self-contained piece to contribute from this issue. The JAX backend part lives in pytensor (a separate repo), so that would be a follow-up contribution if you want to go further.test_printing already existed so i created
test_print_value.py11:17 PMSmart move. Now let's make sure your test file is properly structured and doesn't clash with anything in the existing test_printing.py. What does the existing file test?
bash# Run this in your cloned repo to see what's already there:
cat tests/test_printing.py
Also run:
bashgrep -n "print_value|Print" tests/test_printing.py
Share the output and I'll help you make sure your test_print_value.py doesn't duplicate anything, has the right imports, and is structured to pass cleanly. Then we can get your PR opened.