Skip to content

Feature/print value helper#8229

Open
krishnavallabha wants to merge 8 commits intopymc-devs:v6from
krishnavallabha:feature/print-value-helper
Open

Feature/print value helper#8229
krishnavallabha wants to merge 8 commits intopymc-devs:v6from
krishnavallabha:feature/print-value-helper

Conversation

@krishnavallabha
Copy link
Copy Markdown

Summary

Adds a pm.print_value() helper function as proposed in #6841.

Previously, users had to manually initialize pytensor.printing.Print
which is an unusual API. This helper wraps that op with a clean,
discoverable interface.

Usage

with pm.Model():
    x = pm.Normal("x", mu=0, sigma=1)
    x = pm.print_value(x, name="x")  # prints x during sampling

Changes

  • pymc/printing.py — new print_value() helper
  • pymc/__init__.py — expose as pm.print_value
  • tests/test_print_value.py — tests for pass-through and naming

Closes #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.

Copilot AI review requested due to automatic review settings March 28, 2026 17:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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’s Print op.
  • Exposes the helper from the pymc top-level namespace as pm.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.

Comment on lines +1 to +7
# pymc/printing.py

"""Helper utilities for debugging PyMC models."""

from pytensor.printing import Print

__all__ = ["print_value"]
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Krishna Vallabha and others added 5 commits March 28, 2026 23:29
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>
@read-the-docs-community
Copy link
Copy Markdown

Documentation build overview

📚 pymc | 🛠️ Build #32019226 | 📁 Comparing 6a03ab9 against latest (0f5c0ca)


🔍 Preview build

Show files changed (24 files in total): 📝 24 modified | ➕ 0 added | ➖ 0 deleted
File Status
glossary.html 📝 modified
contributing/developer_guide.html 📝 modified
_modules/pymc/pytensorf.html 📝 modified
_modules/pymc/testing.html 📝 modified
api/generated/pymc.draw.html 📝 modified
api/generated/pymc.icdf.html 📝 modified
api/generated/pymc.logcdf.html 📝 modified
api/generated/pymc.logp.html 📝 modified
api/generated/pymc.sample_posterior_predictive.html 📝 modified
api/generated/pymc.sample_prior_predictive.html 📝 modified
_modules/pymc/distributions/continuous.html 📝 modified
_modules/pymc/distributions/distribution.html 📝 modified
_modules/pymc/distributions/shape_utils.html 📝 modified
_modules/pymc/logprob/basic.html 📝 modified
_modules/pymc/model/core.html 📝 modified
_modules/pymc/ode/ode.html 📝 modified
_modules/pymc/sampling/forward.html 📝 modified
_modules/pymc/variational/approximations.html 📝 modified
_modules/pymc/variational/operators.html 📝 modified
_modules/pymc/variational/opvi.html 📝 modified
_modules/pytensor/tensor/basic.html 📝 modified
_modules/pytensor/tensor/math.html 📝 modified
api/distributions/generated/classmethods/pymc.SymbolicRandomVariable.update.html 📝 modified
api/model/generated/classmethods/pymc.model.core.Model.compile_fn.html 📝 modified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: Improve debug docs and function helpers

2 participants