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

Test docstring examples #546

Open
bveeramani opened this issue Apr 12, 2022 · 0 comments
Open

Test docstring examples #546

bveeramani opened this issue Apr 12, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@bveeramani
Copy link
Member

bveeramani commented Apr 12, 2022

Description

Add a job named doctest to the test.yml workflow. The job should run doctest against the examples in the nums package.

Use case

#153 added docstrings to functions. Now that we have examples in our code, we should ensure that examples run correctly because:

  1. Incorrect examples are frustrating for the user.
  2. If we test examples, we'll be more confident about the correctness of NumS.

For example, the examples in #436 should be tested.

    Examples
    --------
    Convert a list into an array:
    >>> a = [1, 2]
    >>> nps.asarray(a).get()
    array([1, 2])

    Existing arrays are not copied:
    >>> a = nps.array([1, 2])
    >>> nps.asarray(a) is a
    True

    If `dtype` is set, array is copied only if dtype does not match:
    >>> a = nps.array([1, 2], dtype=np.float32)
    >>> nps.asarray(a, dtype=np.float32) is a
    True
    >>> nps.asarray(a, dtype=np.float64) is a
    False

Open Questions

  • Which Python versions should we run doctests against?
  • Which backends should we run doctests against?
  • Should doctests be part of a new job, or should we add them to the existing pytest job? (In this case, we'd want to rename the pytest job)
@bveeramani bveeramani added the enhancement New feature or request label Apr 12, 2022
@bveeramani bveeramani changed the title Test examples in the docstrings Test docstring examples Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants