Stopgaps - Utilities

Skip to content
Back to top
View this page
Edit this page

# Stopgaps

exception sage.misc.stopgap.StopgapWarning

  Bases: `Warning`

  This class is used to warn users of a known issue that may produce mathematically incorrect results.

sage.misc.stopgap.set_state(mode)

  Enable or disable the stopgap warnings.

  INPUT:

  - `mode` – boolean; if `True`, enable stopgaps. Otherwise, disable.

  EXAMPLES:

  Sage

      sage: import sage.misc.stopgap
      sage: sage.misc.stopgap.set_state(False)
      sage: sage.misc.stopgap.stopgap("Displays nothing.", 12345)
      sage: sage.misc.stopgap.set_state(True)
      sage: sage.misc.stopgap.stopgap("Displays something.", 123456)
      doctest:...:
      ...StopgapWarning: Displays something.
      This issue is being tracked at https://github.com/sagemath/sage/issues/123456.
      sage: sage.misc.stopgap.set_state(False)

  Python

      >>> from sage.all import *
      >>> import sage.misc.stopgap
      >>> sage.misc.stopgap.set_state(False)
      >>> sage.misc.stopgap.stopgap("Displays nothing.", Integer(12345))
      >>> sage.misc.stopgap.set_state(True)
      >>> sage.misc.stopgap.stopgap("Displays something.", Integer(123456))
      doctest:...:
      ...StopgapWarning: Displays something.
      This issue is being tracked at https://github.com/sagemath/sage/issues/123456.
      >>> sage.misc.stopgap.set_state(False)

sage.misc.stopgap.stopgap(message, issue_no)

  Issue a stopgap warning.

  INPUT:

  - `message` – an explanation of how an incorrect answer might be produced

  - `issue_no` – integer; giving the number of the Github issue tracking the underlying issue

  EXAMPLES:

  Sage

      sage: import sage.misc.stopgap
      sage: sage.misc.stopgap.set_state(True)
      sage: sage.misc.stopgap.stopgap("Computation of heights on elliptic curves over number fields can return very imprecise results.", 12509)
      doctest:...
      ...StopgapWarning: Computation of heights on elliptic curves over number fields can return very imprecise results.
      This issue is being tracked at https://github.com/sagemath/sage/issues/12509.
      sage: sage.misc.stopgap.stopgap("This is not printed", 12509)
      sage: sage.misc.stopgap.set_state(False)  # so rest of doctesting fine

  Python

      >>> from sage.all import *
      >>> import sage.misc.stopgap
      >>> sage.misc.stopgap.set_state(True)
      >>> sage.misc.stopgap.stopgap("Computation of heights on elliptic curves over number fields can return very imprecise results.", Integer(12509))
      doctest:...
      ...StopgapWarning: Computation of heights on elliptic curves over number fields can return very imprecise results.
      This issue is being tracked at https://github.com/sagemath/sage/issues/12509.
      >>> sage.misc.stopgap.stopgap("This is not printed", Integer(12509))
      >>> sage.misc.stopgap.set_state(False)  # so rest of doctesting fine