sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.44k stars 481 forks source link

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

Closed mkoeppe closed 4 years ago

mkoeppe commented 4 years ago

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

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:

Depends on #29892

CC: @fchapoton @tscrim @dkrenn @mwageringel

Component: refactoring

Author: Daniel Krenn, Matthias Koeppe

Branch/Commit: 8d7609e

Reviewer: Travis Scrimshaw, Markus Wageringel

Issue created by migration from https://trac.sagemath.org/ticket/29895

mkoeppe commented 4 years ago

Description changed:

--- 
+++ 
@@ -2,8 +2,9 @@

 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` is used in sagelib.
-`set_verbose` is used in doctests of sagelib.
+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.
mkoeppe commented 4 years ago

Description changed:

--- 
+++ 
@@ -12,5 +12,5 @@

 See also:
 - #21349: build verbose upon Python's logging module
+- #17815: Remove verbose from the global namespace

-
mkoeppe commented 4 years ago
comment:3

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

mkoeppe commented 4 years ago

Author: Daniel Krenn, Matthias Koeppe

mkoeppe commented 4 years ago

Description changed:

--- 
+++ 
@@ -6,8 +6,9 @@

 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.
+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 deprecate the import of `verbose` into `sage.misc.all` as proposed in #17815.

 See also:
mkoeppe commented 4 years ago

Branch: u/mkoeppe/move_sage_misc_miscverboseto_new_module_sage_misc_verbose

mkoeppe commented 4 years ago
comment:7

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
mkoeppe commented 4 years ago

Commit: 2363642

mkoeppe commented 4 years ago

Description changed:

--- 
+++ 
@@ -1,12 +1,14 @@
 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`.
+- 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.
+- Only `verbose` and `get_verbose` are used in sagelib.

-Additionally, `set_verbose` is used in doctests of 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.
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from 2363642 to d8abdb0

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

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
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

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

db40fd5Fix pyflakes warnings regarding imports
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from d8abdb0 to db40fd5

mkoeppe commented 4 years ago
comment:12

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

tscrim commented 4 years ago
comment:13

LGTM.

tscrim commented 4 years ago

Reviewer: Travis Scrimshaw

mkoeppe commented 4 years ago
comment:14

Thank you!

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from db40fd5 to df742b1

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

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
vbraun commented 4 years ago
comment:17

Merge conflict

mkoeppe commented 4 years ago

Dependencies: #29892

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from df742b1 to ceaf817

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

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
mkoeppe commented 4 years ago
comment:20

Trivial merge to resolve conflict

vbraun commented 4 years ago
comment:21
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
----------------------------------------------------------------------
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from ceaf817 to 8d7609e

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

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

8d7609esrc/sage/algebras/splitting_algebra.py: from sage.misc.verbose import verbose
mwageringel commented 4 years ago

Changed reviewer from Travis Scrimshaw to Travis Scrimshaw, Markus Wageringel

mwageringel commented 4 years ago
comment:24

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

mkoeppe commented 4 years ago
comment:25

Thanks!

vbraun commented 4 years ago

Changed branch from u/mkoeppe/move_sage_misc_miscverboseto_new_module_sage_misc_verbose to 8d7609e