Skip to content

Deprecate SumTo1 transform#8356

Open
andreruizloera wants to merge 1 commit into
pymc-devs:mainfrom
andreruizloera:deprecate-sumto1-7009
Open

Deprecate SumTo1 transform#8356
andreruizloera wants to merge 1 commit into
pymc-devs:mainfrom
andreruizloera:deprecate-sumto1-7009

Conversation

@andreruizloera

Copy link
Copy Markdown

Closes #7009.

Adds a FutureWarning when SumTo1 is instantiated or when pymc.distributions.transforms.sum_to_1 is accessed, per maintainer guidance in the issue ("We can warn first"). The module-level sum_to_1 instance is now served lazily via a module __getattr__ (the same pattern used in pymc/logprob/utils.py) so that importing PyMC emits no warning; only actual access does. The transform remains fully functional.

Includes a test verifying the warning fires on both access paths and that the transform still works. Existing functional tests were switched to a single warning-suppressed instance so the suite stays warning-clean, including at collection time (two usages live inside @pytest.mark.parametrize decorators, which evaluate when tests are collected).

Verification

  • python -W error::FutureWarning -c "import pymc" is clean (no warning on import)
  • Accessing tr.sum_to_1 and calling tr.SumTo1() both raise the FutureWarning
  • from pymc.distributions.transforms import * still exposes sum_to_1
  • Full tests/distributions/test_transform.py suite: 78 passed
  • ruff check and ruff format --check clean on both modified files

Checklist

  • Tests added (test_sum_to_1_deprecated)
  • Docstring updated with a deprecation note

Emit a FutureWarning when SumTo1 is instantiated or when pymc.distributions.transforms.sum_to_1 is accessed, per maintainer guidance in pymc-devs#7009. The module-level sum_to_1 instance is now served lazily via a module __getattr__ so importing PyMC emits no warning; only actual access does. The transform remains fully functional.

Includes a test verifying the warning fires on both access paths and that the transform still works.
name = "sumto1"
ndim_supp = 1

def __init__(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it's enough to deprecate access to the sum_to_1 and leave the class noiseless. Less code in this PR and same result, as I don't expect people to be creating their own instances

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

Labels

hackathon Suitable for hackathon maintenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate SumTo1 Transform

2 participants