Skip to content

Add PyMC code examples to math function docstrings #824

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

Closed
wants to merge 9 commits into from

Conversation

fonnesbeck
Copy link
Member

Description

Adding usage examples to docstrings

Fixes issue at pymc-devs/pymc#5537

Related Issue

  • Closes #
  • Related to #

Checklist

Type of change

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

@fonnesbeck
Copy link
Member Author

Going to do a few more before merge, if these look good.


.. code:: python

with pm.Model():
Copy link
Member

Choose a reason for hiding this comment

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

Import pymc, use pm.math.switch? For a fully reproducible snippet and emphasize math module

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we use pm.math or pt, since this is in the pytensor repo?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I didn't even realize this was in the pytensor repo. These examples should be in PyMC and in the PyMC math module docs. It doesn't make sense to mention PyMC in PyTensor

Copy link
Member Author

Choose a reason for hiding this comment

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

The API docs currently use the docstrings from the PyTensor functions. Do we need to create explicit wrappers in PyMC?

Copy link
Member

Choose a reason for hiding this comment

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

We can add more stuff in the docs page than the default docstrings I think (or completely override the defaults).


with pm.Model() as model:
weights = pm.Gamma('weights', 1, 1, shape=3)
softmax_prob = pt.softmax(weights)
Copy link
Member

Choose a reason for hiding this comment

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

Same

Copy link

codecov bot commented Jun 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.87%. Comparing base (efa845a) to head (8b62e81).
Report is 160 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #824   +/-   ##
=======================================
  Coverage   80.87%   80.87%           
=======================================
  Files         163      163           
  Lines       46852    46852           
  Branches    11464    11464           
=======================================
  Hits        37892    37892           
  Misses       6750     6750           
  Partials     2210     2210           
Files with missing lines Coverage Δ
pytensor/tensor/basic.py 88.42% <ø> (ø)
pytensor/tensor/extra_ops.py 88.60% <ø> (ø)
pytensor/tensor/math.py 90.43% <ø> (ø)
pytensor/tensor/special.py 92.10% <ø> (ø)

@ricardoV94
Copy link
Member

Besides the question of adding PyMC-centric examples, we should definitely scratch the default Elemwise docstrings that we are getting now and which you see when you go to the math module in PyMC. That's just useless gibberish.

Mentioned in the understated: #292

@fonnesbeck
Copy link
Member Author

Might be easiest then to have explicit wrappers to dispatch to PyTensor and override the docstrings.

@fonnesbeck fonnesbeck closed this Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants