#29895 closed enhancement (fixed)

move sage.misc.misc.*verbose* to new module sage.misc.verbose

Reported by: mkoeppe Owned by:
Priority: major Milestone: sage-9.2
Component: refactoring Keywords:
Cc: chapoton, tscrim, dkrenn, gh-mwageringel Merged in:
Authors: Daniel Krenn, Matthias Koeppe Reviewers: Travis Scrimshaw, Markus Wageringel
Report Upstream: N/A Work issues:
Branch: 8d7609e (Commits, GitHub, GitLab) Commit: 8d7609eac1bebbaca15996a86a587c2c9ffbcc05
Dependencies: #29892 Stopgaps:

Status badges

Description (last modified by mkoeppe)

The "simple verbosity system" in sage.misc.misc has 2 global variables, LEVEL and verbose_files, which are meant to be internal.

  • Access is through functions verbose, set_verbose, set_verbose_files, get_verbose_files, unset_verbose_files, get_verbose, all of which are imported by sage.misc.all.
  • Only verbose and get_verbose are used in sagelib.
  • Additionally, set_verbose is used in doctests of sagelib.

We move the functions to a new module sage.misc.verbose, with lazy_import and deprecation. This is preparation for #21349, and is also helpful for #29865 (modularization).

We also add some documentation taken from #21349.

We also deprecate the import of verbose into sage.misc.all as proposed in #17815.

See also:

  • #21349: build verbose upon Python's logging module
  • #17815: Remove verbose from the global namespace

Change History (26)

comment:1 Changed 11 months ago by mkoeppe

  • Description modified (diff)

comment:2 Changed 11 months ago by mkoeppe

  • Cc chapoton tscrim added
  • Description modified (diff)

comment:3 Changed 11 months ago by mkoeppe

  • Cc dkrenn added

We can reuse some of the commits of #21349 for this ticket.

comment:4 Changed 11 months ago by mkoeppe

  • Authors set to Daniel Krenn, Matthias Koeppe

comment:5 Changed 11 months ago by mkoeppe

  • Description modified (diff)

comment:6 Changed 11 months ago by mkoeppe

  • Branch set to u/mkoeppe/move_sage_misc_misc__verbose__to_new_module_sage_misc_verbose

comment:7 Changed 11 months ago by mkoeppe

  • Commit set to 23636427fb8b083bc06124c6493aa2764d6fbbf8

The branch does not work yet because it the moved functions depend on cputime from sage.misc.misc and other missing imports


Last 10 new commits:

a5453bfFixup: Add src/sage/misc/call.py
64c5701lazy_import from sage.misc.call with deprecation
65414f7Fix imports and one deprecation warning
b9314d4sage.misc.call: Add standard header information, add to reference manual
6024ffdsrc/sage/misc/call.py: register_unpickle_override for call_method
e8ad8d3sage.misc.verbose: New module
ad01c5fsage.misc.misc: Move *verbose* to sage.misc.verbose
67f7eb2sage.misc.all: Import *verbose* from sage.misc.verbose, deprecate import of function verbose
8068325sage.misc.misc: lazy_import *verbose* with deprecation
2363642fixup

comment:8 Changed 11 months ago by mkoeppe

  • Description modified (diff)

comment:9 Changed 11 months ago by git

  • Commit changed from 23636427fb8b083bc06124c6493aa2764d6fbbf8 to d8abdb06b865ada8cc7fa306602f9121da64a427

Branch pushed to git repo; I updated commit sha1. This was a forced push. Last 10 new commits:

68da7f5replace all of sage.misc.*verbose by sage.verbose.*verbose
55ec500resolve verbose-nameclash
c9eb31dReplace imports *verbose* from sage.misc.all by imports from sage.misc.verbose
06dcba2sage.plot.graphics: Use warnings.warn instead of nonexisting sage.misc.misc.warn
210c1a7sage.plot: Import sage.misc.verbose
8a5e384Fix remaining imports of *verbose*
5632556src/sage/modular/modsym/relation_matrix_pyx.pyx: Fixup import
41d42e9sage.misc.verbose: Fix imports
b3af9e2sage.misc.verbose: Fix doctest
d8abdb0Fixup various imports and uses of verbose

comment:10 Changed 11 months ago by mkoeppe

  • Status changed from new to needs_review

comment:11 Changed 11 months ago by git

  • Commit changed from d8abdb06b865ada8cc7fa306602f9121da64a427 to db40fd553880dd48ca94fe4a7554d19205c7270b

Branch pushed to git repo; I updated commit sha1. New commits:

db40fd5Fix pyflakes warnings regarding imports

comment:12 Changed 11 months ago by mkoeppe

The remaining patchbot plugin warnings are old news. Needs review.

comment:13 Changed 11 months ago by tscrim

  • Reviewers set to Travis Scrimshaw
  • Status changed from needs_review to positive_review

LGTM.

comment:14 Changed 11 months ago by mkoeppe

Thank you!

comment:15 Changed 11 months ago by git

  • Commit changed from db40fd553880dd48ca94fe4a7554d19205c7270b to df742b13b3127b42485b99362c1fb2da69de5b37
  • Status changed from positive_review to needs_review

Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:

df742b1Merge tag '9.2.beta3' into t/29895/move_sage_misc_misc__verbose__to_new_module_sage_misc_verbose

comment:16 Changed 11 months ago by mkoeppe

  • Status changed from needs_review to positive_review

comment:17 Changed 11 months ago by vbraun

  • Status changed from positive_review to needs_work

Merge conflict

comment:18 Changed 10 months ago by mkoeppe

  • Dependencies set to #29892

comment:19 Changed 10 months ago by git

  • Commit changed from df742b13b3127b42485b99362c1fb2da69de5b37 to ceaf81749f221d0055e6820108a48a14d41631dd

Branch pushed to git repo; I updated commit sha1. New commits:

3f5b6eaMove sage.misc.misc.coeff_repr, repr_lincomb to new module sage.misc.repr
08fedfasrc/sage/combinat/root_system/type_dual.py: Remove unused variable to fix pyflakes warning
05efc11sage.misc.repr.coeff_repr: Add doctest, adapted from sage.misc.latex.coeff_repr
538323bsrc/sage/misc/call.py: Fix block syntax in docstring
b5f63a5src/sage/misc/call.py: Returns should be Return
ceaf817Merge branch 't/29892/move_sage_misc_misc_coeff_repr__repr_lincomb_to_new_module_sage_misc_repr' into t/29895/move_sage_misc_misc__verbose__to_new_module_sage_misc_verbose

comment:20 Changed 10 months ago by mkoeppe

  • Status changed from needs_work to positive_review

Trivial merge to resolve conflict

comment:21 Changed 10 months ago by vbraun

  • Status changed from positive_review to needs_work
sage -t --long --warn-long 36.6 src/sage/algebras/splitting_algebra.py
**********************************************************************
File "src/sage/algebras/splitting_algebra.py", line 56, in sage.algebras.splitting_algebra.SplittingAlgebraElement
Failed example:
    CR6.<e6> = SplittingAlgebra(cp6)
Expected nothing
Got:
    doctest:warning
      File "/home/release/Sage/src/bin/sage-runtests", line 177, in <module>
        err = DC.run()
      File "/home/release/Sage/local/lib/python3.7/site-packages/sage/doctest/control.py", line 1207, in run
        self.run_doctests()
      File "/home/release/Sage/local/lib/python3.7/site-packages/sage/doctest/control.py", line 908, in run_doctests
        self.dispatcher.dispatch()
      File "/home/release/Sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 2038, in dispatch
        self.parallel_dispatch()
      File "/home/release/Sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 1933, in parallel_dispatch
        w.start()  # This might take some time
      File "/home/release/Sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 2205, in start
        super(DocTestWorker, self).start()
      File "/home/release/Sage/local/lib/python3.7/multiprocessing/process.py", line 112, in start
        self._popen = self._Popen(self)
      File "/home/release/Sage/local/lib/python3.7/multiprocessing/context.py", line 223, in _Popen
        return _default_context.get_context().Process._Popen(process_obj)
      File "/home/release/Sage/local/lib/python3.7/multiprocessing/context.py", line 277, in _Popen
        return Popen(process_obj)
      File "/home/release/Sage/local/lib/python3.7/multiprocessing/popen_fork.py", line 20, in __init__
        self._launch(process_obj)
      File "/home/release/Sage/local/lib/python3.7/multiprocessing/popen_fork.py", line 74, in _launch
        code = process_obj._bootstrap()
      File "/home/release/Sage/local/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
        self.run()
      File "/home/release/Sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 2177, in run
        task(self.options, self.outtmpfile, msgpipe, self.result_queue)
      File "/home/release/Sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 2506, in __call__
        doctests, extras = self._run(runner, options, results)
      File "/home/release/Sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 2552, in _run
        result = runner.run(test)
      File "/home/release/Sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 905, in run
        return self._run(test, compileflags, out)
      File "/home/release/Sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 707, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/release/Sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 1131, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.algebras.splitting_algebra.SplittingAlgebraElement[2]>", line 1, in <module>
        CR6 = SplittingAlgebra(cp6, names=('e6',)); (e6,) = CR6._first_ngens(1)
      File "/home/release/Sage/local/lib/python3.7/site-packages/sage/algebras/splitting_algebra.py", line 224, in __init__
        % (base_ring, monic_polynomial, iterate, warning))
      File "/home/release/Sage/local/lib/python3.7/site-packages/sage/misc/superseded.py", line 100, in deprecation
        warning(trac_number, message, DeprecationWarning, stacklevel)
      File "/home/release/Sage/local/lib/python3.7/site-packages/sage/misc/superseded.py", line 146, in warning
        warn(message, warning_class, stacklevel)
      File "/home/release/Sage/local/lib/python3.7/warnings.py", line 110, in _showwarnmsg
        msg.file, msg.line)
    :
    DeprecationWarning: 
    Importing verbose from here is deprecated. If you need to use it, please import it directly from sage.misc.verbose
    See http://trac.sagemath.org/17815 for details.
**********************************************************************
1 item had failures:
   1 of   6 in sage.algebras.splitting_algebra.SplittingAlgebraElement
    [107 tests, 1 failure, 0.65 s]
----------------------------------------------------------------------
sage -t --long --warn-long 36.6 src/sage/algebras/splitting_algebra.py  # 1 doctest failed
----------------------------------------------------------------------

comment:22 Changed 10 months ago by git

  • Commit changed from ceaf81749f221d0055e6820108a48a14d41631dd to 8d7609eac1bebbaca15996a86a587c2c9ffbcc05

Branch pushed to git repo; I updated commit sha1. New commits:

8d7609esrc/sage/algebras/splitting_algebra.py: from sage.misc.verbose import verbose

comment:23 Changed 10 months ago by mkoeppe

  • Cc gh-mwageringel added
  • Status changed from needs_work to needs_review

comment:24 Changed 10 months ago by gh-mwageringel

  • Reviewers changed from Travis Scrimshaw to Travis Scrimshaw, Markus Wageringel
  • Status changed from needs_review to positive_review

The fix looks good to me and the bot is green.

comment:25 Changed 10 months ago by mkoeppe

Thanks!

comment:26 Changed 10 months ago by vbraun

  • Branch changed from u/mkoeppe/move_sage_misc_misc__verbose__to_new_module_sage_misc_verbose to 8d7609eac1bebbaca15996a86a587c2c9ffbcc05
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.