Skip to content

Doctest # optional / # long annotation dataflow checker #35401

@mkoeppe

Description

@mkoeppe

Is there an existing issue for this?

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.

Problem Description

It is easy to make mistakes when using # optional - FEATURE and # long time annotations in doctests.

For example, in the following doctests, a # long time annotation is missing, causing a failure when sage -t is used without --long.

src/sage/coding/ag_code_decoders.pyx:    sage: code = codes.EvaluationAGCode(pls, G)  # long time
src/sage/coding/ag_code_decoders.pyx:    sage: code                                   # long time
src/sage/coding/ag_code_decoders.pyx-    [26, 15] evaluation AG code over GF(9)
src/sage/coding/ag_code_decoders.pyx:    sage: decoder = code.decoder('K')
src/sage/coding/ag_code_decoders.pyx:    sage: tau = decoder.decoding_radius()        # long time
src/sage/coding/ag_code_decoders.pyx:    sage: tau                                    # long time

As part of

we expect to add many more # optional annotations corresponding to "standard" packages such as # optional - scipy and corresponding to subset distributions such as # optional - sage.libs.pari.

Proposed Solution

The Sage doctester has a rudimentary data flow analyzer for the globals involved in the lines of a doctest, globs: RecordingDict, which is used for determining dependencies for parallelization purposes.

We can extend this mechanism to track the set of features (# optional tags) and the pseudo-feature long associated with each doctest line. For each variable in RecordingDict.got of a doctest_line, we check that the set of required features

  • is a superset of the set of required features of a predecessor of doctest_line that has variable in predecessor.globs.set,
  • or a proper generalization of this.

Alternatives Considered

N/A

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions