Skip to content

Commit

Permalink
Trac #33364: remove traces of # py3 and some # py2
Browse files Browse the repository at this point in the history
There still remains a lot of `# py2` tags in explain_pickle, see #33144

URL: https://trac.sagemath.org/33364
Reported by: chapoton
Ticket author(s): Frédéric Chapoton
Reviewer(s): Michael Orlitzky
  • Loading branch information
Release Manager committed Feb 21, 2022
2 parents 518f9fc + bf7b549 commit d2b071e
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 53 deletions.
3 changes: 2 additions & 1 deletion src/sage/doctest/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

# Optional tags which are always automatically added

auto_optional_tags = set(['py3'])
auto_optional_tags = set()

try:
from sage.libs.arb.arb_version import version as arb_vers
Expand All @@ -56,6 +56,7 @@
except ImportError:
pass


class DocTestDefaults(SageObject):
"""
This class is used for doctesting the Sage doctest module.
Expand Down
3 changes: 1 addition & 2 deletions src/sage/doctest/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from .external import available_software

float_regex = re.compile(r'\s*([+-]?\s*((\d*\.?\d+)|(\d+\.?))([eE][+-]?\d+)?)')
optional_regex = re.compile(r'(arb216|arb218|py2|py3|long time|not implemented|not tested|known bug)|([^ a-z]\s*optional\s*[:-]*((\s|\w|[.])*))')
optional_regex = re.compile(r'(arb216|arb218|py2|long time|not implemented|not tested|known bug)|([^ a-z]\s*optional\s*[:-]*((\s|\w|[.])*))')
# Version 4.65 of glpk prints the warning "Long-step dual simplex will
# be used" frequently. When Sage uses a system installation of glpk
# which has not been patched, we need to ignore that message.
Expand Down Expand Up @@ -129,7 +129,6 @@ def parse_optional_tags(string):
- 'not tested'
- 'known bug'
- 'py2'
- 'py3'
- 'arb216'
- 'arb218'
- 'optional: PKG_NAME' -- the set will just contain 'PKG_NAME'
Expand Down
32 changes: 10 additions & 22 deletions src/sage/libs/ntl/ntl_GF2X.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,12 @@ cdef class ntl_GF2X(object):
return [self[i] for i in range(GF2X_deg(self.x)+1)]

def bin(ntl_GF2X self):
"""
Returns binary representation of this element. It is
the same as setting \code{ntl.GF2XHexOutput(False)} and
r"""
Returns binary representation of this element.
It is the same as setting \code{ntl.GF2XHexOutput(False)} and
representing this element afterwards. However it should be
faster and preserves the HexOutput state as opposed to
the above code.
faster and preserves the HexOutput state as opposed to the above code.
EXAMPLES::
Expand All @@ -498,7 +498,8 @@ cdef class ntl_GF2X(object):
'[1 1 0 1 1 1 0 0 1]'
OUTPUT:
string representing this element in binary digits
string representing this element in binary digits
"""
cdef long _hex = GF2XHexOutput_c[0]
GF2XHexOutput_c[0] = 0
Expand All @@ -507,13 +508,12 @@ cdef class ntl_GF2X(object):
return s

def hex(ntl_GF2X self):
"""
r"""
Return an hexadecimal representation of this element.
It is the same as setting \code{ntl.GF2XHexOutput(True)} and
representing this element afterwards. However it should be
faster and preserves the HexOutput state as opposed to the
above code.
representing this element afterwards. However it should be faster and
preserves the HexOutput state as opposed to the above code.
OUTPUT:
Expand All @@ -524,25 +524,13 @@ cdef class ntl_GF2X(object):
sage: e = ntl.GF2X([1,1,0,1,1,1,0,0,1])
sage: e.hex()
'0xb31'
TESTS::
sage: hex(e) # py2
doctest:warning...:
DeprecationWarning: use the method .hex instead
See http://trac.sagemath.org/24514 for details.
'0xb31'
"""
cdef long _hex = GF2XHexOutput_c[0]
GF2XHexOutput_c[0] = 1
s = ccrepr(self.x)
GF2XHexOutput_c[0] = _hex
return s

def __hex__(self):
deprecation(24514, 'use the method .hex instead')
return self.hex()

def __hash__(self):
return hash(self.hex())

Expand Down
13 changes: 5 additions & 8 deletions src/sage/matroids/matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ cdef class Matroid(SageObject):
while cur != len(S):
cur = len(S)
cl = frozenset([])
for T in combinations(S, min(k,cur)):
for T in combinations(S, min(k, cur)):
cl = cl.union(self._closure(set(T)))
S = cl
return S
Expand Down Expand Up @@ -3721,18 +3721,15 @@ cdef class Matroid(SageObject):
sage: M = matroids.named_matroids.Vamos()
sage: N = M.minor('abc', 'defg')
sage: N # py2
sage: N
M / {'a', 'b', 'c'} \ {'d', 'e', 'f', 'g'}, where M is Vamos:
Matroid of rank 4 on 8 elements with circuit-closures
{3: {{'a', 'b', 'c', 'd'}, {'a', 'b', 'e', 'f'},
{'a', 'b', 'g', 'h'}, {'c', 'd', 'e', 'f'},
{'e', 'f', 'g', 'h'}},
4: {{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'}}}
...
sage: N.groundset()
frozenset({'h'})
sage: N = M.minor('defgh', 'abc')
sage: N # py2
sage: N # random
M / {'d', 'e', 'f', 'g'} \ {'a', 'b', 'c', 'h'}, where M is Vamos:
Matroid of rank 4 on 8 elements with circuit-closures
{3: {{'a', 'b', 'c', 'd'}, {'a', 'b', 'e', 'f'},
Expand Down Expand Up @@ -6350,7 +6347,7 @@ cdef class Matroid(SageObject):
sage: M.is_circuit_chordal(['a','b','d','e'])
True
sage: X = M.is_circuit_chordal(frozenset(['a','b','d','e']), certificate=True)[1]
sage: X # py2
sage: X # random
('c', frozenset({'b', 'c', 'd'}), frozenset({'a', 'c', 'e'}))
sage: M.is_circuit(X[1]) and M.is_circuit(X[2])
True
Expand Down
16 changes: 5 additions & 11 deletions src/sage/misc/classcall_metaclass.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -467,20 +467,10 @@ def typecall(pytype cls, *args, **kwds):
[]
sage: typecall(Integer, 2)
2
.. warning::
:func:`typecall` doesn't work for old style class (not inheriting from
:class:`object`)::
sage: class Bar: pass
sage: typecall(Bar) # py2
Traceback (most recent call last):
...
TypeError: Argument 'cls' has incorrect type (expected type, got classobj)
"""
return (<PyTypeObject*>type).tp_call(cls, args, kwds)


# Class for timing::

class CRef(object):
Expand All @@ -494,6 +484,7 @@ class CRef(object):
"""
self.i = i+1


class C2(object, metaclass=ClasscallMetaclass):
def __init__(self, i):
"""
Expand All @@ -505,6 +496,7 @@ class C2(object, metaclass=ClasscallMetaclass):
"""
self.i = i+1


class C3(object, metaclass = ClasscallMetaclass):
def __init__(self, i):
"""
Expand All @@ -516,6 +508,7 @@ class C3(object, metaclass = ClasscallMetaclass):
"""
self.i = i+1


class C2C(object, metaclass=ClasscallMetaclass):
@staticmethod
def __classcall__(cls, i):
Expand All @@ -528,6 +521,7 @@ class C2C(object, metaclass=ClasscallMetaclass):
"""
return i+1


def timeCall(T, int n, *args):
r"""
We illustrate some timing when using the classcall mechanism.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/sageinspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,7 @@ def sage_formatargspec(args, varargs=None, varkw=None, defaults=None,
sage: defaults = [3]
sage: sage_formatargspec(args, defaults=defaults)
'(a, b, c=3)'
sage: import warnings; warnings.simplefilter('ignore') # py3: ignore DeprecationWarning
sage: import warnings; warnings.simplefilter('ignore') # ignore DeprecationWarning
sage: formatargspec(args, defaults=defaults) == sage_formatargspec(args, defaults=defaults)
True
"""
Expand Down
8 changes: 0 additions & 8 deletions src/sage/rings/integer_ring.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -579,14 +579,6 @@ cdef class IntegerRing_class(PrincipalIdealDomain):
4
sage: f(-7r)
-7
Note that the input *MUST* be an ``int``::
sage: a = 10000000000000000000000rL
sage: f(a) # py2
Traceback (most recent call last):
...
TypeError: must be a Python int object
"""
if S is long:
return sage.rings.integer.long_to_Z()
Expand Down

0 comments on commit d2b071e

Please sign in to comment.