Skip to content

Spurious warnings about optional tags #36920

@kwankyu

Description

@kwankyu

Steps To Reproduce

From sage-devel thread

https://groups.google.com/g/sage-devel/c/kagz-697Hts


[David Coudert] observed some doctest warnings that I don't know how to fix. This is certainly a side effect of the modularization.

File "src/sage/plot/plot.py", line 569, in sage.plot.plot
Warning: Variable 'sig_on_count' referenced here was set only in doctest marked '# needs sage.symbolic'
    sig_on_count() # check sig_on/off pairings (virtual doctest)
**********************************************************************
File "src/sage/plot/plot.py", line 3623, in sage.plot.plot.graphics_array
Warning: Variable 'x' referenced here was set only in doctest marked '# long time, needs sage.symbolic'
    L = [plot(sin(k*x), (x,-pi,pi)) for k in [1..3]]
**********************************************************************
File "src/sage/plot/plot.py", line 3669, in sage.plot.plot.graphics_array
Warning: Variable 'x' referenced here was set only in doctest marked '# long time, needs sage.symbolic'
    p1 = plot(sin(x^2), (x, 0, 6),
              axes_labels=[r'$\theta$', r'$\sin(\theta^2)$'], fontsize=16)
**********************************************************************
File "src/sage/plot/plot.py", line 3671, in sage.plot.plot.graphics_array
Warning: Variable 'x' referenced here was set only in doctest marked '# long time, needs sage.symbolic'
    p2 = plot(x^3, (x, 1, 100), axes_labels=[r'$x$', r'$y$'],
              scale='semilogy', frame=True, gridlines='minor')

File "src/sage/repl/user_globals.py", line 52, in sage.repl.user_globals
Warning: Variable 'sig_on_count' referenced here was set only in doctest marked '# needs sage.modules'
    sig_on_count() # check sig_on/off pairings (virtual doctest)
**********************************************************************
File "src/sage/repl/user_globals.py", line 99, in sage.repl.user_globals.get_globals
Warning: Variable 'sig_on_count' referenced here was set only in doctest marked '# needs sage.modules'
    sig_on_count() # check sig_on/off pairings (virtual doctest)

An initial investigation suggests:

The string sig_on_count() # check sig_on/off pairings (virtual doctest) is from src/sage/doctest/sources.py line 234.
As I understand it, the warning is caused by a bug in the method _create_doctests() in the same file, which fails to add optional tags correctly to the string.

Expected Behavior

No warning.

Actual Behavior

Spurious warnings

Additional Information

@mkoeppe would know how to fix it.

Environment

- **OS**:
- **Sage Version**:

Checklist

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions