Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

Test docstring examples #546

@bveeramani

Description

@bveeramani

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)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions