Skip to content
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

Censor & Truncate Docstrings #7590

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

Conversation

RyanAugust
Copy link

@RyanAugust RyanAugust commented Nov 26, 2024

Description

Provides updated type listing for lower and upper censor & truncate points to include int and array-like.
Additionally, provides an example using -/+inf for partial censor or truncation.

Related Issue

Checklist

Type of change

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

📚 Documentation preview 📚: https://pymc--7590.org.readthedocs.build/en/7590/

Copy link

welcome bot commented Nov 26, 2024

Thank You Banner]
💖 Thanks for opening this pull request! 💖 The PyMC community really appreciates your time and effort to contribute to the project. Please make sure you have read our Contributing Guidelines and filled in our pull request template to the best of your ability.

@RyanAugust RyanAugust changed the title Censor Docs Censor & Truncate Docstrings Nov 26, 2024
Comment on lines 293 to 295
with pm.Model():
normal_dist = pm.Normal.dist(mu=0.0, sigma=1.0)
partially_truncated_normal = pm.Truncated("partially_truncated_normal", normal_dist, lower=-np.inf, upper=1)
Copy link
Member

@ricardoV94 ricardoV94 Nov 26, 2024

Choose a reason for hiding this comment

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

Let's put it a s a separate example for more readability with a header explaning it. And include multiple variates like lower=[-np.inf, -np.inf, 0, 0], upper=[np.inf, 1, np.inf, 1], shape=(4,)) explaining that the first one is not truncated / censored, the second one only from above, the third one only from below, and the last one from both sides.

.. code-block:: python

with pm.Model():
normal_dist = pm.Normal.dist(mu=0.0, sigma=1.0)
truncated_normal = pm.Truncated("truncated_normal", normal_dist, lower=-1, upper=1)

Partial truncatin of normal distributions achieved by passing +/-inf truncation points.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Partial truncatin of normal distributions achieved by passing +/-inf truncation points.
Partial truncation of normal distributions achieved by passing +/-inf truncation points.

Comment on lines +111 to +112
Partial censoring of normal distributions achienved by passing +/-inf censor points.
Examples of 4 censor conditions: uncensored (-inf, inf), upper censored (-inf, 1),
Copy link
Member

Choose a reason for hiding this comment

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

First emphasize that censoring bounds can change across dimensions of the variable, and then enumerate the examples. If they don't change, one can use None as upper or lower, not only +/-np.inf

.. code-block:: python
with pm.Model():
normal_dist = pm.Normal.dist(mu=0.0, sigma=1.0)
partially_censored_normals = pm.Censored("partially_censored_normals", normal_dist, lower=[-np.inf, -np.inf, -1, -1], upper=[np.inf, 1, np.inf, 1], shape=(4,))
Copy link
Member

@ricardoV94 ricardoV94 Nov 27, 2024

Choose a reason for hiding this comment

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

make it multiple line so it renders nicely in the docs: https://pymcio--7590.org.readthedocs.build/projects/docs/en/7590/api/distributions/censored.html

The name is probably too long

Partial censoring of normal distributions achienved by passing +/-inf censor points.
Examples of 4 censor conditions: uncensored (-inf, inf), upper censored (-inf, 1),
lower censored (-1, inf), and both censored (-1, 1)
.. code-block:: python
Copy link
Member

Choose a reason for hiding this comment

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

I think you need to leave a blank line between the description and the code example for it to render correctly: https://pymcio--7590.org.readthedocs.build/projects/docs/en/7590/api/distributions/censored.html

Before: https://www.pymc.io/projects/docs/en/stable/api/distributions/censored.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants