BUG: Unexpected keyword arguments like `sd=10` are dropped

Open
#8,607 5 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Start by reading Normal.dist and HalfNormal.dist in PyMC alongside RandomVariable.__call__ in pytensor/tensor/random/op.py, the path named in the issue. Trace how sd and unknown keyword arguments reach the random variable call, then check the relevant tests for distribution arguments. Done means sd=10 no longer silently produces the default sigma and unsupported keywords such as bogus are handled explicitly.

Written by the indexing model from the issue text.

Description

Describe the issue:

pm.Normal("x", mu=0, sd=10) builds Normal(0, 1): Normal.dist forwards sd through **kwargs, and RandomVariable.__call__ in pytensor/tensor/random/op.py drops it. bogus=10 is dropped too, and pm.HalfNormal("x", sd=10) gets sigma 1.

Reproduceable code example:
import pymc as pm

with pm.Model() as m:
    stated = pm.Normal("stated", mu=0, sd=10)      # means: standard deviation 10
    correct = pm.Normal("correct", mu=0, sigma=10)  # means: standard deviation 10
    default = pm.Normal("default", mu=0)            # means: standard deviation 1

print([p.eval() for p in stated.owner.inputs[2:]])   # [0, 1.0]   <- sd=10 was dropped
print([p.eval() for p in correct.owner.inputs[2:]])  # [0, 10]
print([p.eval() for p in default.owner.inputs[2:]])  # [0, 1.0]
Error message:

No error and no warning.

PyMC version information:

PyMC 6.3.2 (PyTensor 3.3.4) and 6.4.0 (PyTensor 3.3.7), Python 3.12.13

Context for the issue:

Older PyMC raised a TypeError for sd=, so code that used to fail now builds a different model.

Dominant language
Python
Stars
9.9k
Forks
2.4k
Avg merge
4d 10h
Merged PRs (30d)
12

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pymc-devs/pymc

All issues in pymc-devs/pymc

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.