Skip to content
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

[FEA] Use doctest for testing python docstrings #981

Closed
benfred opened this issue Nov 2, 2022 · 0 comments · Fixed by #1073
Closed

[FEA] Use doctest for testing python docstrings #981

benfred opened this issue Nov 2, 2022 · 0 comments · Fixed by #1073
Labels
feature request New feature or request

Comments

@benfred
Copy link
Member

benfred commented Nov 2, 2022

Is your feature request related to a problem? Please describe.

The example code in the python docstrings isn't being automatically tested right now. This can cause the example docstrings to break over time as the codebase is updated (#980)

We should add tests to make sure that the example code blocks in our python docstrings can run successfully

Describe the solution you'd like

We can run the example docstrings with our unittests using doctest via the --doctest-modules option in pytest. This is consistent with other rapids projects like cudf

Additional context

This requires changing the format of the docstring code blocks to the numpydoc format ( rapidsai/cudf#652 )

@benfred benfred added the feature request New feature or request label Nov 2, 2022
benfred added a commit to benfred/raft that referenced this issue Dec 7, 2022
Similar to rapidsai/cudf#9815, this change uses doctest
to test that the pylibraft example docstrings run without issue.

This caught several errors in the example docstrings, that are also fixed in this PR:
 *  a missing ‘device_ndarray’ import in kmeans fit when the centroids weren’t explicitly passed in
 *  an error in the fused_l2_nn_argmin docstring where output wasn’t defined
 *  An `AttributeError: module 'pylibraft.neighbors.ivf_pq' has no attribute 'np'` error in ivf_pq

Closes rapidsai#981
@rapids-bot rapids-bot bot closed this as completed in #1073 Dec 7, 2022
rapids-bot bot pushed a commit that referenced this issue Dec 7, 2022
Similar to rapidsai/cudf#9815, this change uses doctest to test that the pylibraft example docstrings run without issue.

This caught several errors in the example docstrings, that are also fixed in this PR:
 *  a missing ‘device_ndarray’ import in kmeans fit when the centroids weren’t explicitly passed in
 *  an error in the fused_l2_nn_argmin docstring where output wasn’t defined
 *  An `AttributeError: module 'pylibraft.neighbors.ivf_pq' has no attribute 'np'` error in ivf_pq

Closes #981

Authors:
  - Ben Frederickson (https://github.com/benfred)

Approvers:
  - Corey J. Nolet (https://github.com/cjnolet)

URL: #1073
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant