Skip to content

Improved docstrings for Elemwise functions #1259

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 2 commits into from

Conversation

twiecki
Copy link
Member

@twiecki twiecki commented Mar 2, 2025

Description

This PR continues and completes the work started in PR #830, improving docstrings for Elemwise functions.

The changes include:

  1. Modifying \ to no longer append generic Elemwise boilerplate to function docstrings
  2. Creating improved docstrings for several core mathematical functions:
    • : Added detailed documentation for the exponential function
    • : Added clear documentation with warnings about negative values
    • : Added explanation of the equality operator with usage examples

The enhanced docstrings follow the NumPy-style with Parameters, Returns, and Examples sections, making them much more useful for both new and experienced users.

Related Issue

This replaces PR #830 which was stalled.


📚 Documentation preview 📚: https://pytensor--1259.org.readthedocs.build/en/1259/

pre-commit-ci bot and others added 2 commits February 24, 2025 17:09
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.7.3 → v0.9.7](astral-sh/ruff-pre-commit@v0.7.3...v0.9.7)
This PR improves docstrings for Elemwise functions by:
1. Modifying scalar_elemwise to no longer append the generic Elemwise docstring
2. Enhancing docstrings for specific mathematical functions (exp, log, eq) with:
   - Better formatted NumPy-style documentation
   - Clear descriptions of functionality
   - Practical usage examples
   - Additional notes on potential pitfalls

This fixes issue #292 which noted that current Elemwise docstrings are
not very helpful due to excessive generic boilerplate.

🤖 Generated with Claude Code
Co-Authored-By: Claude <[email protected]>
Copy link
Member

@ricardoV94 ricardoV94 left a comment

Choose a reason for hiding this comment

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

We merged it already, I thought you saw it: #1255


Notes
-----
This function supports the Python syntax `a == b` when used with PyTensor tensors.
Copy link
Member

Choose a reason for hiding this comment

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

Weird to say this, a == b is explicitly not supported, I guess an "equivalent" is missing

@twiecki twiecki closed this Mar 5, 2025
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.

DOC: Docstrings for Elemwise Ops are not very helpful
2 participants