Skip to content

Commit da024a0

Browse files
committed
pep8 cleanup in repl/ and sat/
1 parent b9e396a commit da024a0

File tree

13 files changed

+52
-52
lines changed

13 files changed

+52
-52
lines changed

src/sage/repl/configuration.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
sage: 'sage: [False, True]' in output # needs pexpect
1616
True
1717
"""
18-
19-
#*****************************************************************************
18+
# ****************************************************************************
2019
# Copyright (C) 2016 Volker Braun <[email protected]>
2120
#
2221
# Distributed under the terms of the GNU General Public License (GPL)
2322
# as published by the Free Software Foundation; either version 2 of
2423
# the License, or (at your option) any later version.
25-
# http://www.gnu.org/licenses/
26-
#*****************************************************************************
24+
# https://www.gnu.org/licenses/
25+
# ****************************************************************************
2726

2827

2928
import sys

src/sage/repl/interpreter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,8 @@ def __init__(self, app):
772772
contact_email = '[email protected]'
773773
bug_tracker = 'https://github.com/sagemath/sage/issues'
774774
CrashHandler.__init__(self,
775-
app, contact_name, contact_email, bug_tracker, show_crash_traceback=True)
775+
app, contact_name, contact_email,
776+
bug_tracker, show_crash_traceback=True)
776777
self.crash_report_fname = 'Sage_crash_report.txt'
777778

778779

src/sage/repl/ipython_extension.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def display(self, args):
302302
max_width = 0
303303
if max_width <= 0:
304304
raise ValueError(
305-
"max width must be a positive integer")
305+
"max width must be a positive integer")
306306
import sage.typeset.character_art as character_art
307307
character_art.MAX_WIDTH = max_width
308308
dm.preferences.text = arg0
@@ -435,7 +435,7 @@ def __init__(self, shell=None):
435435
self.init_line_transforms()
436436

437437
try:
438-
import sage.all # until sage's import hell is fixed
438+
import sage.all # until sage's import hell is fixed
439439
except ImportError:
440440
import sage.all__sagemath_repl
441441

src/sage/repl/rich_output/backend_doctest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
The Sage display manager using the doctest backend
1414
"""
1515

16-
#*****************************************************************************
16+
# ****************************************************************************
1717
# Copyright (C) 2015 Volker Braun <[email protected]>
1818
#
1919
# Distributed under the terms of the GNU General Public License (GPL)
2020
# as published by the Free Software Foundation; either version 2 of
2121
# the License, or (at your option) any later version.
22-
# http://www.gnu.org/licenses/
23-
#*****************************************************************************
22+
# https://www.gnu.org/licenses/
23+
# ****************************************************************************
2424

2525
import sys
2626

@@ -295,7 +295,7 @@ def validate(self, rich_output):
295295
assert data.startswith(b'\0\0\0')
296296
# See http://www.ftyps.com/
297297
ftyps = [data[i:i+4] for i in range(8, data[3], 4)]
298-
del ftyps[1] # version number, not an ftyp
298+
del ftyps[1] # version number, not an ftyp
299299
expected = [b'avc1', b'iso2', b'mp41', b'mp42']
300300
assert any(i in ftyps for i in expected)
301301
elif isinstance(rich_output, OutputVideoFlash):

src/sage/repl/rich_output/backend_ipython.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ def displayhook(self, plain_text, rich_output):
525525
elif isinstance(rich_output, OutputLatex):
526526
return ({'text/latex': rich_output.latex.get_str(),
527527
'text/plain': plain_text.text.get_str(),
528-
}, {})
528+
}, {})
529529
elif isinstance(rich_output, OutputHtml):
530530
data = {'text/html': rich_output.html.get_str(),
531531
'text/plain': plain_text.text.get_str()}
@@ -535,29 +535,29 @@ def displayhook(self, plain_text, rich_output):
535535
elif isinstance(rich_output, OutputImagePng):
536536
return ({'image/png': rich_output.png.get(),
537537
'text/plain': plain_text.text.get_str(),
538-
}, {})
538+
}, {})
539539
elif isinstance(rich_output, OutputImageGif):
540540
return ({'text/html': rich_output.html_fragment(),
541541
'text/plain': plain_text.text.get_str(),
542-
}, {})
542+
}, {})
543543
elif isinstance(rich_output, OutputImageJpg):
544544
return ({'image/jpeg': rich_output.jpg.get(),
545545
'text/plain': plain_text.text.get_str(),
546-
}, {})
546+
}, {})
547547
elif isinstance(rich_output, OutputImageSvg):
548548
return ({'image/svg+xml': rich_output.svg.get(),
549549
'text/plain': plain_text.text.get_str(),
550-
}, {})
550+
}, {})
551551
elif isinstance(rich_output, OutputImagePdf):
552552
return ({'image/png': rich_output.png.get(),
553553
'text/plain': plain_text.text.get_str(),
554-
}, {})
554+
}, {})
555555
elif isinstance(rich_output, OutputSceneJmol):
556556
from sage.repl.display.jsmol_iframe import JSMolHtml
557557
jsmol = JSMolHtml(rich_output, height=500)
558558
return ({'text/html': jsmol.iframe(),
559559
'text/plain': plain_text.text.get_str(),
560-
}, {})
560+
}, {})
561561
elif isinstance(rich_output, OutputSceneThreejs):
562562
escaped_html = html.escape(rich_output.html.get_str())
563563
iframe = IFRAME_TEMPLATE.format(
@@ -567,7 +567,7 @@ def displayhook(self, plain_text, rich_output):
567567
)
568568
return ({'text/html': iframe,
569569
'text/plain': plain_text.text.get_str(),
570-
}, {})
570+
}, {})
571571
else:
572572
raise TypeError('rich_output type not supported')
573573

src/sage/repl/rich_output/output_basic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ class is independent of user preferences and of the display
3232
file system.
3333
"""
3434

35-
#*****************************************************************************
35+
# ****************************************************************************
3636
# Copyright (C) 2015 Volker Braun <[email protected]>
3737
#
3838
# Distributed under the terms of the GNU General Public License (GPL)
3939
# as published by the Free Software Foundation; either version 2 of
4040
# the License, or (at your option) any later version.
41-
# http://www.gnu.org/licenses/
42-
#*****************************************************************************
41+
# https://www.gnu.org/licenses/
42+
# ****************************************************************************
4343

4444

4545
from sage.structure.sage_object import SageObject

src/sage/repl/rich_output/output_catalog.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
If you define another output type then you must add it to the imports here.
66
"""
77

8-
#*****************************************************************************
8+
# ****************************************************************************
99
# Copyright (C) 2015 Volker Braun <[email protected]>
1010
#
1111
# Distributed under the terms of the GNU General Public License (GPL)
1212
# as published by the Free Software Foundation; either version 2 of
1313
# the License, or (at your option) any later version.
14-
# http://www.gnu.org/licenses/
15-
#*****************************************************************************
14+
# https://www.gnu.org/licenses/
15+
# ****************************************************************************
1616

1717

1818
from .output_basic import (

src/sage/repl/rich_output/test_backend.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
TestOutputPlainText container
3131
"""
3232

33-
#*****************************************************************************
33+
# ****************************************************************************
3434
# Copyright (C) 2015 Volker Braun <[email protected]>
3535
#
3636
# Distributed under the terms of the GNU General Public License (GPL)
3737
# as published by the Free Software Foundation; either version 2 of
3838
# the License, or (at your option) any later version.
39-
# http://www.gnu.org/licenses/
40-
#*****************************************************************************
39+
# https://www.gnu.org/licenses/
40+
# ****************************************************************************
4141

4242

4343
from sage.structure.sage_object import SageObject

src/sage/sat/boolean_polynomials.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ def solve(F, converter=None, solver=None, n=1, target_variables=None, **kwds):
303303
if S[0] is None:
304304
return None
305305
elif S[-1] is False:
306-
return S[0:-1]
306+
return S[0:-1]
307307
return S
308308

309309

@@ -395,7 +395,7 @@ def learn(F, converter=None, solver=None, max_learnt_length=3, interreduction=Fa
395395
try:
396396
lc = solver.learnt_clauses()
397397
except (AttributeError, NotImplementedError):
398-
# solver does not support recovering learnt clauses
398+
# solver does not support recovering learnt clauses
399399
lc = []
400400
for c in lc:
401401
if len(c) <= max_learnt_length:

src/sage/sat/converters/polybori.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def __init__(self, solver, ring, max_vars_sparse=6, use_xor_clauses=None, cuttin
128128
self.cutting_number = cutting_number
129129

130130
if use_xor_clauses is None:
131-
use_xor_clauses = hasattr(solver,"add_xor_clause")
131+
use_xor_clauses = hasattr(solver, "add_xor_clause")
132132
self.use_xor_clauses = use_xor_clauses
133133

134134
self.ring = ring
@@ -222,7 +222,7 @@ def choose(s):
222222
indices.append(nav.value())
223223
nav = t
224224
else:
225-
if self.random_generator.randint(0,1):
225+
if self.random_generator.randint(0, 1):
226226
indices.append(nav.value())
227227
nav = t
228228

@@ -337,11 +337,11 @@ def clauses_dense(self, f):
337337
for fpart, this_equal_zero in self.split_xor(f, equal_zero):
338338
ll = len(fpart)
339339
for p in self.permutations(ll, this_equal_zero):
340-
self.solver.add_clause([ p[i]*fpart[i] for i in range(ll) ])
340+
self.solver.add_clause([p[i] * fpart[i] for i in range(ll)])
341341
else:
342342
ll = len(f)
343343
for p in self.permutations(ll, equal_zero):
344-
self.solver.add_clause([ p[i]*f[i] for i in range(ll) ])
344+
self.solver.add_clause([p[i] * f[i] for i in range(ll)])
345345

346346
@cached_method
347347
def monomial(self, m):
@@ -387,19 +387,19 @@ def monomial(self, m):
387387
For correctness, this function is cached.
388388
"""
389389
if m.deg() == 1:
390-
return m.index()+1
391-
else:
392-
# we need to encode the relationship between the monomial
393-
# and its variables
394-
variables = [self.monomial(v) for v in m.variables()]
395-
monomial = self.var(m)
390+
return m.index() + 1
396391

397-
# (a | -w) & (b | -w) & (w | -a | -b) <=> w == a*b
398-
for v in variables:
399-
self.solver.add_clause( (v, -monomial) )
400-
self.solver.add_clause( tuple([monomial] + [-v for v in variables]) )
392+
# we need to encode the relationship between the monomial
393+
# and its variables
394+
variables = [self.monomial(v) for v in m.variables()]
395+
monomial = self.var(m)
396+
397+
# (a | -w) & (b | -w) & (w | -a | -b) <=> w == a*b
398+
for v in variables:
399+
self.solver.add_clause((v, -monomial))
400+
self.solver.add_clause(tuple([monomial] + [-v for v in variables]))
401401

402-
return monomial
402+
return monomial
403403

404404
@cached_function
405405
def permutations(length, equal_zero):

0 commit comments

Comments
 (0)