From 8ffbb9425056a8eac19ccbbe64f9613d8ea64cdc Mon Sep 17 00:00:00 2001 From: Jeroen Demeyer Date: Fri, 16 Sep 2016 17:14:29 +0200 Subject: [PATCH] Remove some deprecated code --- src/sage/functions/airy.py | 1 - src/sage/functions/special.py | 4 +-- src/sage/groups/perm_gps/all.py | 3 --- src/sage/libs/linbox/linbox.pyx | 2 +- src/sage/misc/all.py | 10 +------- src/sage/misc/functional.py | 41 ------------------------------- src/sage/misc/interpreter.py | 3 --- src/sage/misc/misc.py | 29 +--------------------- src/sage/misc/misc_c.pyx | 7 ------ src/sage/misc/temporary_file.py | 14 +---------- src/sage/modules/all.py | 3 --- src/sage/plot/graphics.py | 42 +++----------------------------- src/sage/repl/load.py | 43 --------------------------------- src/sage/structure/coerce.pyx | 3 --- 14 files changed, 9 insertions(+), 196 deletions(-) delete mode 100644 src/sage/misc/interpreter.py diff --git a/src/sage/functions/airy.py b/src/sage/functions/airy.py index ec1579fae19..9d6b8b3576f 100644 --- a/src/sage/functions/airy.py +++ b/src/sage/functions/airy.py @@ -48,7 +48,6 @@ from sage.symbolic.function import BuiltinFunction from sage.symbolic.expression import Expression from sage.symbolic.ring import SR -from sage.structure.coerce import parent as sage_structure_coerce_parent from sage.functions.other import gamma from sage.rings.integer_ring import ZZ from sage.rings.real_double import RDF diff --git a/src/sage/functions/special.py b/src/sage/functions/special.py index c39c1f84c04..f6ddcff4241 100644 --- a/src/sage/functions/special.py +++ b/src/sage/functions/special.py @@ -168,9 +168,7 @@ from sage.symbolic.function import BuiltinFunction, is_inexact from sage.symbolic.expression import Expression from sage.calculus.calculus import maxima -from sage.structure.coerce import parent -from sage.structure.element import get_coercion_model -from sage.structure.parent import Parent +from sage.structure.element import parent from sage.libs.mpmath import utils as mpmath_utils from sage.functions.all import sqrt, sin, cot, exp from sage.symbolic.all import I diff --git a/src/sage/groups/perm_gps/all.py b/src/sage/groups/perm_gps/all.py index 0ef588fb57f..28b026fc864 100644 --- a/src/sage/groups/perm_gps/all.py +++ b/src/sage/groups/perm_gps/all.py @@ -16,6 +16,3 @@ PermutationGroupMorphism = PermutationGroupMorphism_im_gens from .cubegroup import CubeGroup, RubiksCube - -from sage.misc.lazy_import import lazy_import -lazy_import("sage.groups.perm_gps", "permgroup", "pg", deprecation=18140) diff --git a/src/sage/libs/linbox/linbox.pyx b/src/sage/libs/linbox/linbox.pyx index 7c1087ca506..4c0837af575 100644 --- a/src/sage/libs/linbox/linbox.pyx +++ b/src/sage/libs/linbox/linbox.pyx @@ -8,7 +8,7 @@ Linbox interface from sage.libs.gmp.mpz cimport * from sage.rings.integer cimport Integer -from sage.misc.misc import verbose, get_verbose, cputime, UNAME +from sage.misc.misc import verbose, get_verbose ########################################################################## ## Sparse matrices modulo p. diff --git a/src/sage/misc/all.py b/src/sage/misc/all.py index 377a45090fa..bdd492faf96 100644 --- a/src/sage/misc/all.py +++ b/src/sage/misc/all.py @@ -23,7 +23,6 @@ from .temporary_file import tmp_dir, tmp_filename from .misc_c import prod, running_total, balanced_sum -lazy_import('sage.misc.misc_c', ['is_32_bit', 'is_64_bit'], deprecation=17460) mul = prod add = sum @@ -82,8 +81,6 @@ lazy_import("sage.misc.cython", ["cython_lambda", "cython_create_local_so"]) lazy_import("sage.misc.cython_c", "cython_compile", "cython") -lazy_import("sage.misc.cython_c", "cython_compile", "pyrex", deprecation=9552) -lazy_import("sage.misc.cython_c", "cython_compile", "sagex", deprecation=9552) from .persist import save, load, dumps, loads, db, db_save @@ -134,7 +131,6 @@ n, N, objgens, objgen, - one, order, rank, regulator, @@ -145,7 +141,7 @@ squarefree_part, symbolic_sum as sum, transpose, - zero) + ) from .latex import LatexExpr, latex, view, pretty_print_default @@ -201,7 +197,3 @@ def _latex_(self): elif not '~' in self: delim = '~' return r"""\verb%s%s%s"""%(delim, self.replace('\n\n','\n').replace('\n','; '), delim) - - -lazy_import("sage.misc", "messaging", deprecation=18140) - diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py index bdf7cb60cfd..1ff6c75ebc3 100644 --- a/src/sage/misc/functional.py +++ b/src/sage/misc/functional.py @@ -1321,26 +1321,6 @@ def objgen(x): """ return x.objgen() -def one(R): - """ - Returns the one element of the ring R. - - EXAMPLES:: - - sage: one(RR) - doctest:...: DeprecationWarning: one(R) is deprecated, use R.one() or R(1) instead - See http://trac.sagemath.org/17158 for details. - 1.00000000000000 - sage: R. = PolynomialRing(QQ) - sage: one(R)*x == x - True - sage: one(R) in R - True - """ - from sage.misc.superseded import deprecation - deprecation(17158, 'one(R) is deprecated, use R.one() or R(1) instead') - return R(1) - def order(x): """ Returns the order of x. If x is a ring or module element, this is @@ -1554,24 +1534,3 @@ def transpose(x): [3 6 9] """ return x.transpose() - - -def zero(R): - """ - Returns the zero element of the ring R. - - EXAMPLES:: - - sage: zero(RR) - doctest:...: DeprecationWarning: zero(R) is deprecated, use R.zero() or R(0) instead - See http://trac.sagemath.org/17158 for details. - 0.000000000000000 - sage: R. = PolynomialRing(QQ) - sage: zero(R) in R - True - sage: zero(R)*x == zero(R) - True - """ - from sage.misc.superseded import deprecation - deprecation(17158, 'zero(R) is deprecated, use R.zero() or R(0) instead') - return R(0) diff --git a/src/sage/misc/interpreter.py b/src/sage/misc/interpreter.py deleted file mode 100644 index eb07a897011..00000000000 --- a/src/sage/misc/interpreter.py +++ /dev/null @@ -1,3 +0,0 @@ -from sage.misc.lazy_import import lazy_import - -lazy_import('sage.repl.interpreter', '_do_preparse', 'do_preparse', deprecation=17460) diff --git a/src/sage/misc/misc.py b/src/sage/misc/misc.py index 18bdd784cb4..2625b8f26c8 100644 --- a/src/sage/misc/misc.py +++ b/src/sage/misc/misc.py @@ -44,11 +44,6 @@ Importing sxrange from here is deprecated. If you need to use it, please import it directly from sage.arith.srange See http://trac.sagemath.org/20094 for details. - sage: sage.misc.misc.mul([3,4]) - doctest:...: DeprecationWarning: - Importing prod from here is deprecated. If you need to use it, please import it directly from sage.misc.all - See http://trac.sagemath.org/17460 for details. - 12 sage: sage.misc.misc.cancel_alarm() doctest:...: DeprecationWarning: Importing cancel_alarm from here is deprecated. If you need to use it, please import it directly from cysignals.alarm @@ -80,13 +75,7 @@ from sage.misc.lazy_import import lazy_import lazy_import('sage.arith.srange', ('xsrange', 'srange', 'ellipsis_range', 'ellipsis_iter'), deprecation=20094) lazy_import('sage.arith.srange', 'xsrange', 'sxrange', deprecation=20094) -lazy_import('sage.misc.temporary_file', ('tmp_dir', 'tmp_filename', 'delete_tmpfiles'), deprecation=17460) -lazy_import('sage.misc.banner', ('version', 'banner'), deprecation=17460) -lazy_import('sage.env', '*', deprecation=17460) -lazy_import('sage.misc.decorators', ('infix_operator', 'decorator_defaults', 'sage_wraps'), deprecation=17460) -lazy_import('sage.misc.all', ('prod', 'running_total', 'balanced_sum', 'is_64_bit', 'is_32_bit'), deprecation=17460) lazy_import('cysignals.alarm', ('alarm', 'cancel_alarm'), deprecation=20002) -mul = prod from sage.env import DOT_SAGE, HOSTNAME @@ -680,7 +669,7 @@ def coeff_repr(c, is_latex=False): return "(%s)"%s return s -def repr_lincomb(terms, coeffs = None, is_latex=False, scalar_mult="*", strip_one=False, repr_monomial = None, latex_scalar_mult = None): +def repr_lincomb(terms, is_latex=False, scalar_mult="*", strip_one=False, repr_monomial = None, latex_scalar_mult = None): """ Compute a string representation of a linear combination of some formal symbols. @@ -757,23 +746,7 @@ def repr_lincomb(terms, coeffs = None, is_latex=False, scalar_mult="*", strip_on sage: repr_lincomb([('a',1), ('b',2), ('c',3)], repr_monomial = lambda s: s+"1") 'a1 + 2*b1 + 3*c1' - - - TESTS: - - For backward compatibility (will be deprecated):: - - sage: repr_lincomb(['a','b','c'], [1,2,3]) - doctest:...: DeprecationWarning: calling `repr_lincomb(monoms, coeffs)` is deprecated; please specify a list of tuples (monom, coeff) instead - See http://trac.sagemath.org/12484 for details. - 'a + 2*b + 3*c' """ - # For backward compatibility - if coeffs is not None: - from sage.misc.superseded import deprecation - deprecation(12484, "calling `repr_lincomb(monoms, coeffs)` is deprecated; please specify a list of tuples (monom, coeff) instead") - terms = zip(terms, coeffs) - # Setting scalar_mult: symbol used for scalar multiplication if is_latex: if latex_scalar_mult is not None: diff --git a/src/sage/misc/misc_c.pyx b/src/sage/misc/misc_c.pyx index 1dc7a386892..48388b407d9 100644 --- a/src/sage/misc/misc_c.pyx +++ b/src/sage/misc/misc_c.pyx @@ -426,13 +426,6 @@ cdef balanced_list_sum(L, Py_ssize_t offset, Py_ssize_t count, Py_ssize_t cutoff return balanced_list_sum(L, offset, k, cutoff) + balanced_list_sum(L, offset + k, count - k, cutoff) -################################################################# -# 32/64-bit computer? -################################################################# -is_64_bit = sys.maxsize >= 9223372036854775807 -is_32_bit = not is_64_bit - - cpdef list normalize_index(object key, int size): """ Normalize an index key and return a valid index or list of indices diff --git a/src/sage/misc/temporary_file.py b/src/sage/misc/temporary_file.py index 0907b8a4ff0..0cabfd0ed2c 100644 --- a/src/sage/misc/temporary_file.py +++ b/src/sage/misc/temporary_file.py @@ -185,21 +185,8 @@ def graphics_filename(ext='.png'): True sage: fn.endswith('.jpeg') True - - Historically, it was also possible to omit the dot. This has been - changed in :trac:`16640` but it will still work for now:: - - sage: fn = graphics_filename("jpeg") - doctest:...: DeprecationWarning: extension must now include the dot - See http://trac.sagemath.org/16640 for details. - sage: fn.endswith('.jpeg') - True """ import sage.plot.plot - from sage.misc.superseded import deprecation - if ext[0] not in '.-': - deprecation(16640, "extension must now include the dot") - ext = '.' + ext if sage.plot.plot.EMBEDDED_MODE: # Don't use this unsafe function except in the notebook, #15515 i = 0 @@ -208,6 +195,7 @@ def graphics_filename(ext='.png'): filename = 'sage%d%s'%(i,ext) return filename else: + from sage.misc.superseded import deprecation deprecation(17234,'use tmp_filename instead') return tmp_filename(ext=ext) diff --git a/src/sage/modules/all.py b/src/sage/modules/all.py index c9c418169d6..ac1e32769e4 100644 --- a/src/sage/modules/all.py +++ b/src/sage/modules/all.py @@ -25,9 +25,6 @@ from .vector_space_morphism import linear_transformation from sage.misc.lazy_import import lazy_import -lazy_import("sage.modules", - ("vector_symbolic_dense", "vector_callable_symbolic_dense"), - deprecation=18140) lazy_import('sage.modules.filtered_vector_space', 'FilteredVectorSpace') lazy_import('sage.modules.multi_filtered_vector_space', 'MultiFilteredVectorSpace') diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py index c5a38e7c7bb..8e21923c2d6 100644 --- a/src/sage/plot/graphics.py +++ b/src/sage/plot/graphics.py @@ -1342,7 +1342,7 @@ def _set_scale(self, figure, scale=None, base=None): labelspacing=0.02, loc='best', markerscale=0.6, ncol=1, numpoints=2, shadow=True, title=None) - def show(self, filename=None, linkmode=False, **kwds): + def show(self, **kwds): r""" Show this graphics image immediately. @@ -2003,31 +2003,7 @@ def show(self, filename=None, linkmode=False, **kwds): ... ValueError: figsize should be a positive number or a list of two positive numbers, not [2, 3, 4] sage: P.show(figsize=[sqrt(2),sqrt(3)]) - - :: - - sage: P = plot(x^2,(x,0,1)) - sage: P.show(linkmode=True) - doctest:...: DeprecationWarning: the filename and linkmode arguments are deprecated, use save() to save - See http://trac.sagemath.org/17234 for details. - doctest:...: DeprecationWarning: use tmp_filename instead - See http://trac.sagemath.org/17234 for details. - "" - """ - if filename or linkmode: - from sage.misc.superseded import deprecation - deprecation(17234,'the filename and linkmode arguments are deprecated, ' - 'use save() to save') - if filename is None: - from sage.misc.temporary_file import graphics_filename - filename = graphics_filename() - self.save(filename, **kwds) - if linkmode: - return "" % filename - else: - html("" % filename) - return - + """ from sage.repl.rich_output import get_display_manager dm = get_display_manager() dm.display_immediately(self, **kwds) @@ -3078,7 +3054,7 @@ def save_image(self, filename=None, *args, **kwds): labelspacing=0.02, loc='best', markerscale=0.6, ncol=1, numpoints=2, shadow=True, title=None) - def save(self, filename=None, **kwds): + def save(self, filename, **kwds): r""" Save the graphics to an image file. @@ -3172,11 +3148,6 @@ def save(self, filename=None, **kwds): transparent = options.pop('transparent') fig_tight = options.pop('fig_tight') - if filename is None: - from sage.misc.superseded import deprecation - deprecation(17234,'the filename argument is now mandatory') - from sage.misc.temporary_file import graphics_filename - filename = graphics_filename() ext = os.path.splitext(filename)[1].lower() if ext not in ALLOWED_EXTENSIONS: @@ -3591,7 +3562,7 @@ def append(self, g): # Not clear if there is a way to do this raise NotImplementedError('Appending to a graphics array is not yet implemented') - def save(self, filename=None, dpi=DEFAULT_DPI, figsize=None, axes=None, + def save(self, filename, dpi=DEFAULT_DPI, figsize=None, axes=None, **kwds): r""" Save the graphics array. @@ -3636,11 +3607,6 @@ def save(self, filename=None, dpi=DEFAULT_DPI, figsize=None, axes=None, """ if figsize is not None: self._set_figsize_(figsize) - if filename is None: - from sage.misc.superseded import deprecation - deprecation(17234,'the filename argument is now mandatory') - from sage.misc.temporary_file import graphics_filename - filename = graphics_filename() #glist is a list of Graphics objects: glist = self._glist diff --git a/src/sage/repl/load.py b/src/sage/repl/load.py index 491746fa03d..bf770b7a164 100644 --- a/src/sage/repl/load.py +++ b/src/sage/repl/load.py @@ -195,54 +195,11 @@ def load(filename, globals, attach=False): Traceback (most recent call last): ... IOError: did not find file 'this file should not exist' to load or attach - - Evaluating a filename is deprecated:: - - sage: sage.repl.load.load("tmp_filename(ext='.py')", globals()) - doctest:...: DeprecationWarning: using unevaluated expressions as argument to load() is dangerous and deprecated - See http://trac.sagemath.org/17654 for details. - - Test filenames separated by spaces (deprecated):: - - sage: t = tmp_filename(ext='.py') - sage: with open(t, 'w') as f: - ....: f.write("print 'hello'\n") - sage: sage.repl.load.load(t + " " + t, globals()) - hello - hello - doctest:...: DeprecationWarning: using multiple filenames separated by spaces as load() argument is dangerous and deprecated - See http://trac.sagemath.org/17654 for details. """ if attach: from sage.repl.attach import add_attached_file filename = os.path.expanduser(filename) - if not os.path.exists(filename): - try: - # Try *evaluating* the filename - filename = eval(filename, globals).strip() - except Exception: - # Handle multiple input files separated by spaces, which was - # maybe a bad idea, but which we have to handle for backwards - # compatibility. - v = filename.split() - if len(v) > 1: - try: - for f in v: - load(f, globals, attach=attach) - except IOError: - # Splitting the filename didn't work, pretend it - # didn't happen :-) - pass - else: - # Only show deprecation message if the filename - # splitting worked. - from sage.misc.superseded import deprecation - deprecation(17654, 'using multiple filenames separated by spaces as load() argument is dangerous and deprecated') - return - else: - from sage.misc.superseded import deprecation - deprecation(17654, 'using unevaluated expressions as argument to load() is dangerous and deprecated') if filename.lower().startswith(('http://', 'https://')): if attach: diff --git a/src/sage/structure/coerce.pyx b/src/sage/structure/coerce.pyx index c30527835db..8b1cddace26 100644 --- a/src/sage/structure/coerce.pyx +++ b/src/sage/structure/coerce.pyx @@ -94,9 +94,6 @@ from sage.categories.map cimport Map from sage.categories.morphism import IdentityMorphism from sage.categories.action cimport Action, InverseAction, PrecomposedAction -from sage.misc.lazy_import import LazyImport -parent = LazyImport('sage.structure.all', 'parent', deprecation=17533) - import traceback