Skip to content

Commit

Permalink
Trac #21506: Remove some deprecated code
Browse files Browse the repository at this point in the history
Remove code deprecated in #17460, #9552, #18140, #12484, #16640, #17234
(partially because the deprecated code is still used by `animate()`),
#17654, #17158, #17533.

URL: https://trac.sagemath.org/21506
Reported by: jdemeyer
Ticket author(s): Jeroen Demeyer
Reviewer(s): Travis Scrimshaw
  • Loading branch information
Release Manager authored and vbraun committed Sep 17, 2016
2 parents 5021477 + 8ffbb94 commit f728ccc
Show file tree
Hide file tree
Showing 14 changed files with 9 additions and 196 deletions.
1 change: 0 additions & 1 deletion src/sage/functions/airy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/sage/functions/special.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/sage/groups/perm_gps/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion src/sage/libs/linbox/linbox.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 1 addition & 9 deletions src/sage/misc/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -134,7 +131,6 @@
n, N,
objgens,
objgen,
one,
order,
rank,
regulator,
Expand All @@ -145,7 +141,7 @@
squarefree_part,
symbolic_sum as sum,
transpose,
zero)
)


from .latex import LatexExpr, latex, view, pretty_print_default
Expand Down Expand Up @@ -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)

41 changes: 0 additions & 41 deletions src/sage/misc/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.<x> = 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
Expand Down Expand Up @@ -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.<x> = 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)
3 changes: 0 additions & 3 deletions src/sage/misc/interpreter.py

This file was deleted.

29 changes: 1 addition & 28 deletions src/sage/misc/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
<generator object at 0x...>
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 0 additions & 7 deletions src/sage/misc/misc_c.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 1 addition & 13 deletions src/sage/misc/temporary_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
3 changes: 0 additions & 3 deletions src/sage/modules/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
42 changes: 4 additions & 38 deletions src/sage/plot/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
"<img src='cell:///...png'>"
"""
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 "<img src='cell://%s'>" % filename
else:
html("<img src='cell://%s'>" % filename)
return

"""
from sage.repl.rich_output import get_display_manager
dm = get_display_manager()
dm.display_immediately(self, **kwds)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
43 changes: 0 additions & 43 deletions src/sage/repl/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions src/sage/structure/coerce.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit f728ccc

Please sign in to comment.