Skip to content

Commit c02dfc4

Browse files
author
Release Manager
committed
gh-37273: large pep8 cleanup in interfaces just fixing many small code details in `interfaces` folder ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. URL: #37273 Reported by: Frédéric Chapoton Reviewer(s): Frédéric Chapoton, Kwankyu Lee
2 parents 044b3aa + d12bfbc commit c02dfc4

25 files changed

+269
-244
lines changed

src/sage/interfaces/abc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Abstract base classes for interface elements
33
"""
44

5+
56
class AxiomElement:
67
r"""
78
Abstract base class for :class:`~sage.interfaces.axiom.AxiomElement`.

src/sage/interfaces/all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .gap import gap, gap_reset_workspace, Gap
55
from .gp import gp, gp_version, Gp
66
# import problems
7-
#from maxima_lib import maxima_lib
7+
# from maxima_lib import maxima_lib
88
from .maxima import maxima, Maxima
99
from .singular import singular, singular_version, Singular
1010

src/sage/interfaces/chomp.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
from sage.misc.superseded import deprecation
2020

2121
_have_chomp = {}
22+
23+
2224
def have_chomp(program='homsimpl'):
2325
"""
2426
Return True if this computer has ``program`` installed.
@@ -394,7 +396,7 @@ def __call__(self, program, complex, subcomplex=None, **kwds):
394396
for dim in d:
395397
if complex._degree_of_differential == -1: # chain complex
396398
new_dim = bottom + dim
397-
else: # cochain complex
399+
else: # cochain complex
398400
new_dim = top - dim
399401
if isinstance(d[dim], tuple):
400402
# generators included.
@@ -512,6 +514,7 @@ def homsimpl(complex=None, subcomplex=None, **kwds):
512514
else:
513515
raise TypeError("Complex and/or subcomplex are not simplicial complexes.")
514516

517+
515518
def homcubes(complex=None, subcomplex=None, **kwds):
516519
r"""
517520
Compute the homology of a cubical complex using the CHomP program
@@ -743,6 +746,7 @@ def process_generators_cubical(gen_string, dim):
743746
else:
744747
return None
745748

749+
746750
def process_generators_simplicial(gen_string, dim, complex):
747751
r"""
748752
Process CHomP generator information for simplicial complexes.
@@ -829,6 +833,7 @@ def process_generators_simplicial(gen_string, dim, complex):
829833
else:
830834
return None
831835

836+
832837
def process_generators_chain(gen_string, dim, base_ring=None):
833838
r"""
834839
Process CHomP generator information for simplicial complexes.

src/sage/interfaces/four_ti_2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def temp_project(self):
104104
n = 0
105105
while True:
106106
project = "project_%s" % n
107-
touch_file = os.path.join(self.directory(),project) + '.touch'
107+
touch_file = os.path.join(self.directory(), project) + '.touch'
108108
if not os.path.exists(touch_file):
109109
break
110110
n += 1

src/sage/interfaces/gap_workspace.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
Support for (lib)GAP workspace files
33
"""
44

5-
#*****************************************************************************
5+
# ****************************************************************************
66
# Copyright (C) 2017 Jeroen Demeyer <[email protected]>
77
# 2019 Vincent Delecroix <[email protected]>
88
#
99
# This program is free software: you can redistribute it and/or modify
1010
# it under the terms of the GNU General Public License as published by
1111
# the Free Software Foundation, either version 2 of the License, or
1212
# (at your option) any later version.
13-
# http://www.gnu.org/licenses/
14-
#*****************************************************************************
13+
# https://www.gnu.org/licenses/
14+
# ****************************************************************************
1515

1616
import os
1717
import time

src/sage/interfaces/gfan.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#
3838
# The full text of the GPL is available at:
3939
#
40-
# http://www.gnu.org/licenses/
40+
# https://www.gnu.org/licenses/
4141
# *****************************************************************************
4242

4343
from subprocess import Popen, PIPE
@@ -46,6 +46,7 @@
4646

4747
from sage.misc.decorators import rename_keyword
4848

49+
4950
class Gfan():
5051
"""
5152
Interface to Anders Jensen's Groebner Fan program.

src/sage/interfaces/gnuplot.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Interface to the Gnuplot interpreter
33
"""
44

5-
#*****************************************************************************
5+
# ****************************************************************************
66
# Copyright (C) 2005 William Stein <[email protected]>
77
#
88
# Distributed under the terms of the GNU General Public License (GPL)
@@ -14,13 +14,14 @@
1414
#
1515
# The full text of the GPL is available at:
1616
#
17-
# http://www.gnu.org/licenses/
18-
#*****************************************************************************
17+
# https://www.gnu.org/licenses/
18+
# ****************************************************************************
1919

2020
import os
2121
import time
2222
from sage.structure.sage_object import SageObject
2323

24+
2425
class Gnuplot(SageObject):
2526
"""
2627
Interface to the Gnuplot interpreter.
@@ -84,7 +85,7 @@ def plot(self, cmd, file=None, verbose=True, reset=True):
8485
if reset:
8586
self('reset')
8687
self('set terminal x11')
87-
cmd = cmd.replace('^','**')
88+
cmd = cmd.replace('^', '**')
8889
self(cmd)
8990
if file is not None:
9091
if file[-4:] == '.png':
@@ -93,7 +94,7 @@ def plot(self, cmd, file=None, verbose=True, reset=True):
9394
if file[-4:] != '.eps':
9495
file += '.eps'
9596
self('set terminal postscript eps enhanced')
96-
#self("set output '%s'"%file)
97+
# self("set output '%s'"%file)
9798
tmp = 'gnuplot_tmp%s' % file[-4:]
9899
self("set output '%s'" % tmp)
99100
print("Saving plot to %s" % file)
@@ -109,7 +110,7 @@ def plot3d(self, f, xmin=-1, xmax=1, ymin=-1, ymax=1, zmin=-1, zmax=1,
109110
interact=True):
110111
if title is None:
111112
title = str(f)
112-
f = f.replace('^','**')
113+
f = f.replace('^', '**')
113114
cmd = """
114115
set xlabel "%s"
115116
set ylabel "%s"
@@ -126,7 +127,7 @@ def plot3d(self, f, xmin=-1, xmax=1, ymin=-1, ymax=1, zmin=-1, zmax=1,
126127
#show palette
127128
splot %s
128129
""" % (xlabel, ylabel,
129-
xmin, xmax, ymin, ymax, #zmin, zmax,
130+
xmin, xmax, ymin, ymax, # zmin, zmax,
130131
samples, isosamples,
131132
title, f)
132133
if interact:
@@ -172,7 +173,7 @@ def plot3d_parametric(self, f='cos(u)*(3 + v*cos(u/2)), sin(u)*(3 + v*cos(u/2)),
172173
set pm3d; set palette; set parametric
173174
splot %s %s %s
174175
""" % (samples, title, range1, range2, f)
175-
cmd = cmd.replace('^','**')
176+
cmd = cmd.replace('^', '**')
176177
if interact:
177178
self.interact(cmd)
178179
else:

src/sage/interfaces/gp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
#
137137
# Distributed under the terms of the GNU General Public License (GPL)
138138
#
139-
# http://www.gnu.org/licenses/
139+
# https://www.gnu.org/licenses/
140140
#
141141
##########################################################################
142142
import os

src/sage/interfaces/interface.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
- Simon King (2015): Improve pickling for InterfaceElement
2525
"""
2626

27-
#*****************************************************************************
27+
# ****************************************************************************
2828
# Copyright (C) 2005 William Stein <[email protected]>
2929
#
3030
# Distributed under the terms of the GNU General Public License (GPL)
@@ -37,7 +37,7 @@
3737
# The full text of the GPL is available at:
3838
#
3939
# https://www.gnu.org/licenses/
40-
#*****************************************************************************
40+
# ****************************************************************************
4141

4242
import operator
4343

@@ -282,14 +282,14 @@ def __call__(self, x, name=None):
282282
"""
283283
cls = self._object_class()
284284

285-
#Handle the case when x is an object
286-
#in some interface.
285+
# Handle the case when x is an object
286+
# in some interface.
287287
if isinstance(x, InterfaceElement):
288288
if x.parent() is self:
289289
return x
290290

291-
#We convert x into an object in this
292-
#interface by first going through Sage.
291+
# We convert x into an object in this
292+
# interface by first going through Sage.
293293
try:
294294
return self(x._sage_())
295295
except (NotImplementedError, TypeError):
@@ -471,7 +471,7 @@ def set(self, var, value):
471471
"""
472472
Set the variable var to the given value.
473473
"""
474-
cmd = '%s%s%s;' % (var,self._assign_symbol(), value)
474+
cmd = '%s%s%s;' % (var, self._assign_symbol(), value)
475475
self.eval(cmd)
476476

477477
def get(self, var):
@@ -613,7 +613,7 @@ def function_call(self, function, args=None, kwds=None):
613613
self._check_valid_function_name(function)
614614
s = self._function_call_string(function,
615615
[s.name() for s in args],
616-
['%s=%s' % (key,value.name()) for key, value in kwds.items()])
616+
['%s=%s' % (key, value.name()) for key, value in kwds.items()])
617617
return self.new(s)
618618

619619
def _function_call_string(self, function, args, kwds):
@@ -1016,7 +1016,7 @@ def __del__(self):
10161016
self._check_valid()
10171017
except ValueError:
10181018
return
1019-
if hasattr(self,'_name'):
1019+
if hasattr(self, '_name'):
10201020
P = self.parent()
10211021
if P is not None:
10221022
P.clear(self._name)
@@ -1053,9 +1053,9 @@ def _sage_repr(self):
10531053
10541054
- Felix Lawrence (2009-08-21)
10551055
"""
1056-
#TO DO: this could use file transfers when self.is_remote()
1056+
# TO DO: this could use file transfers when self.is_remote()
10571057

1058-
string = repr(self).replace('\n',' ').replace('\r', '')
1058+
string = repr(self).replace('\n', ' ').replace('\r', '')
10591059
# Translate the external program's function notation to Sage's
10601060
lfd = self.parent()._left_func_delim()
10611061
if '(' != lfd:

src/sage/interfaces/magma.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,33 +1303,35 @@ def _object_class(self):
13031303
# It's very painful using the interface without this.
13041304
def _left_list_delim(self):
13051305
"""
1306-
Return the left sequence delimiter in Magma. Despite the name in
1307-
this function, this is really the least painful choice.
1306+
Return the left sequence delimiter in Magma.
1307+
1308+
Despite the name in this function, this is really the least
1309+
painful choice.
13081310
13091311
EXAMPLES::
13101312
13111313
sage: magma._left_list_delim()
13121314
'['
13131315
"""
1314-
#return "[*"
13151316
return "["
13161317

13171318
def _right_list_delim(self):
13181319
"""
1319-
Return the right sequence delimiter in Magma. Despite the name in
1320-
this function, this is really the least painful choice.
1320+
Return the right sequence delimiter in Magma.
1321+
1322+
Despite the name in this function, this is really the least
1323+
painful choice.
13211324
13221325
EXAMPLES::
13231326
13241327
sage: magma._right_list_delim()
13251328
']'
13261329
"""
1327-
#return "*]"
13281330
return "]"
13291331

13301332
def _assign_symbol(self):
13311333
"""
1332-
Returns the assignment symbol in Magma.
1334+
Return the assignment symbol in Magma.
13331335
13341336
EXAMPLES::
13351337
@@ -1340,7 +1342,7 @@ def _assign_symbol(self):
13401342

13411343
def _equality_symbol(self):
13421344
"""
1343-
Returns the equality testing logical symbol in Magma.
1345+
Return the equality testing logical symbol in Magma.
13441346
13451347
EXAMPLES::
13461348
@@ -1351,7 +1353,7 @@ def _equality_symbol(self):
13511353

13521354
def _lessthan_symbol(self):
13531355
"""
1354-
Returns the less than testing logical symbol in Magma.
1356+
Return the less than testing logical symbol in Magma.
13551357
13561358
EXAMPLES::
13571359
@@ -1362,7 +1364,7 @@ def _lessthan_symbol(self):
13621364

13631365
def _greaterthan_symbol(self):
13641366
"""
1365-
Returns the greater than testing logical symbol in Magma.
1367+
Return the greater than testing logical symbol in Magma.
13661368
13671369
EXAMPLES::
13681370
@@ -1375,7 +1377,7 @@ def _greaterthan_symbol(self):
13751377
# in your derived class.
13761378
def _true_symbol(self):
13771379
"""
1378-
Returns the string representation of "truth" in Magma.
1380+
Return the string representation of "truth" in Magma.
13791381
13801382
EXAMPLES::
13811383
@@ -1386,7 +1388,7 @@ def _true_symbol(self):
13861388

13871389
def _false_symbol(self):
13881390
"""
1389-
Returns the string representation of "false" in Magma.
1391+
Return the string representation of "false" in Magma.
13901392
13911393
EXAMPLES::
13921394
@@ -1642,6 +1644,7 @@ def get_nthreads(self):
16421644

16431645
GetNthreads = get_nthreads
16441646

1647+
16451648
@instancedoc
16461649
class MagmaFunctionElement(FunctionElement):
16471650
def __call__(self, *args, **kwds):

0 commit comments

Comments
 (0)