Add docstring examples for Scalar trigonometric functions#1411
Open
ntjohnson1 wants to merge 1 commit intoapache:mainfrom
Open
Add docstring examples for Scalar trigonometric functions#1411ntjohnson1 wants to merge 1 commit intoapache:mainfrom
ntjohnson1 wants to merge 1 commit intoapache:mainfrom
Conversation
Add example usage to docstrings for Scalar trigonometric functions to improve documentation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ntjohnson1
commented
Mar 5, 2026
| @pytest.fixture(autouse=True) | ||
| def _doctest_namespace(doctest_namespace: dict) -> None: | ||
| """Add common imports to the doctest namespace.""" | ||
| doctest_namespace["dfn"] = dfn |
Contributor
Author
There was a problem hiding this comment.
This auto imports dfn and np to save 2 lines in each example.
ntjohnson1
commented
Mar 5, 2026
| >>> from math import pi | ||
| >>> ctx = dfn.SessionContext() | ||
| >>> df = ctx.from_pydict({"a": [pi / 4]}) | ||
| >>> import builtins |
Contributor
Author
There was a problem hiding this comment.
If we don't like builtins then doctest has an ellipses notation for the expected returned values as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
Adding doctested examples to the docstrings makes things nicer to use for humans and agents.
What changes are included in this PR?
The first PR was basically adding a docstring to everything in functions. I broke it apart into a PR (that already merged) for the infra. Then will do a variety of follow ups with groups of functions so it is easier to review. This is the first one to get feedback if this is a reasonable scope. Everything is co-authored with Claude since I used claude to extend the handwritten examples I wrote for reference and to split apart the large PR rather than doing it manually.
I've reviewed all the code prior to PR.
Are there any user-facing changes?
No