Add doctests to functions to help humans and agents#1400
Open
ntjohnson1 wants to merge 5 commits intoapache:mainfrom
Open
Add doctests to functions to help humans and agents#1400ntjohnson1 wants to merge 5 commits intoapache:mainfrom
ntjohnson1 wants to merge 5 commits intoapache:mainfrom
Conversation
…pised pre-commit didn't flag for anyone else
7cfc4d2 to
17b009c
Compare
ntjohnson1
commented
Feb 26, 2026
| >>> builtins.round( | ||
| ... result.collect_column("rad")[0].as_py(), 6 | ||
| ... ) | ||
| 3.141593 |
Contributor
Author
There was a problem hiding this comment.
If you don't like the builtins round we can just use the doctest ellipses approach instead.
ntjohnson1
commented
Feb 26, 2026
Comment on lines
+1473
to
+1474
| >>> import datafusion as dfn | ||
| >>> ctx = dfn.SessionContext() |
Contributor
Author
There was a problem hiding this comment.
I think doctests allows specifying a prefix to always run if the import and ctx feel like too much bloat.
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?
Related to #1394
But I can file another issue.
I generated some examples manually then asked Claude to extend the pattern.
I've looked over the examples and they all seem reasonably minimal and get tested for correctness by doctest.
Rationale for this change
Generally when I am using the dataframe API the docstring/definition alone isn't always sufficient to highlight how or when to use all of the different options. I often find myself generating a small standalone example to verify..
Related to agents they do a great job interpolating so have more small standalone examples for various functionality should help them but I don't have a reference for that.
What changes are included in this PR?
Are there any user-facing changes?
No