Skip to content

Add docstring examples for Scalar trigonometric functions#1411

Open
ntjohnson1 wants to merge 1 commit intoapache:mainfrom
rerun-io:nick/docstrings-scalar-trig
Open

Add docstring examples for Scalar trigonometric functions#1411
ntjohnson1 wants to merge 1 commit intoapache:mainfrom
rerun-io:nick/docstrings-scalar-trig

Conversation

@ntjohnson1
Copy link
Contributor

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

Add example usage to docstrings for Scalar trigonometric functions to improve documentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@pytest.fixture(autouse=True)
def _doctest_namespace(doctest_namespace: dict) -> None:
"""Add common imports to the doctest namespace."""
doctest_namespace["dfn"] = dfn
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This auto imports dfn and np to save 2 lines in each example.

>>> from math import pi
>>> ctx = dfn.SessionContext()
>>> df = ctx.from_pydict({"a": [pi / 4]})
>>> import builtins
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we don't like builtins then doctest has an ellipses notation for the expected returned values as well.

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.

1 participant