Skip to content

Commit

Permalink
Trac #34331: fix E251 in geometry and manifolds
Browse files Browse the repository at this point in the history
about
{{{
E251 unexpected spaces around keyword / parameter equals
}}}

URL: https://trac.sagemath.org/34331
Reported by: chapoton
Ticket author(s): Frédéric Chapoton
Reviewer(s): David Coudert
  • Loading branch information
Release Manager committed Aug 30, 2022
2 parents 544b511 + 0fdd5a2 commit 8ef4334
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 46 deletions.
4 changes: 2 additions & 2 deletions src/sage/geometry/cone.py
Original file line number Diff line number Diff line change
Expand Up @@ -2602,7 +2602,7 @@ def ConeFace(atoms, facets):

self._face_lattice = lattice_from_incidences(
atom_to_facets, facet_to_atoms, ConeFace,
key = id(self))
key=id(self))
else:
# Get face lattice as a sublattice of the ambient one
allowed_indices = frozenset(self._ambient_ray_indices)
Expand Down Expand Up @@ -2642,7 +2642,7 @@ def ConeFace(atoms, facets):
L.add_edge(face_to_index[face], next_index)
D = {i:f for i,f in enumerate(faces)}
L.relabel(D)
self._face_lattice = FinitePoset(L, faces, key = id(self))
self._face_lattice = FinitePoset(L, faces, key=id(self))
return self._face_lattice

# Internally we use this name for a uniform behaviour of cones and fans.
Expand Down
6 changes: 3 additions & 3 deletions src/sage/geometry/hyperplane_arrangement/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,13 @@ def plot_hyperplane(hyperplane, **kwds):
ranges_set = True
ranges = kwds.pop('ranges')
else:
ranges_set = False # give default values below
ranges_set = False # give default values below
# the extra keywords have now been handled
# now create the plot
if hyperplane.dimension() == 0: # a point on a line
if hyperplane.dimension() == 0: # a point on a line
x, = hyperplane.A()
d = hyperplane.b()
p = point((d/x,0), size = pt_size, **kwds)
p = point((d/x,0), size=pt_size, **kwds)
if has_hyp_label:
if not has_offset:
label_offset = 0.1
Expand Down
4 changes: 2 additions & 2 deletions src/sage/geometry/lattice_polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -2022,7 +2022,7 @@ def LPFace(vertices, facets):
ambient_facet_indices=facets)

return lattice_from_incidences(
vertex_to_facets, facet_to_vertices, LPFace, key = id(self))
vertex_to_facets, facet_to_vertices, LPFace, key=id(self))
else:
# Get face lattice as a sublattice of the ambient one
allowed_indices = frozenset(self._ambient_vertex_indices)
Expand Down Expand Up @@ -2061,7 +2061,7 @@ def LPFace(vertices, facets):
L.add_edge(face_to_index[face], next_index)
D = {i:f for i,f in enumerate(faces)}
L.relabel(D)
return FinitePoset(L, faces, key = id(self))
return FinitePoset(L, faces, key=id(self))

def faces(self, dim=None, codim=None):
r"""
Expand Down
24 changes: 13 additions & 11 deletions src/sage/geometry/polyhedron/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ def to_linear_program(self, solver=None, return_variable=False, base_ring=None):

for ineqn in self.inequalities_list():
b = -ineqn.pop(0)
p.add_constraint(p.sum([x[i]*ineqn[i] for i in range(len(ineqn))]) >= b)
p.add_constraint(p.sum([x[i] * ineqn[i] for i in range(len(ineqn))]) >= b)

for eqn in self.equations_list():
b = -eqn.pop(0)
p.add_constraint(p.sum([x[i]*eqn[i] for i in range(len(eqn))]) == b)
p.add_constraint(p.sum([x[i] * eqn[i] for i in range(len(eqn))]) == b)

if return_variable:
return p, x
Expand Down Expand Up @@ -383,7 +383,7 @@ def center(self):
if self.dim() == 0:
return self.vertices()[0].vector()
else:
vertex_sum = vector(self.base_ring(), [0]*self.ambient_dim())
vertex_sum = vector(self.base_ring(), [0] * self.ambient_dim())
for v in self.vertex_generator():
vertex_sum += v.vector()
vertex_sum.set_immutable()
Expand Down Expand Up @@ -1175,15 +1175,17 @@ def _polymake_init_(self):
polymake_class = "Polytope<{}>".format(polymake_field)
if self.is_empty():
# Polymake 3.1 cannot enter an empty polyhedron using
# FACETS and AFFINE_HULL. Use corresponding input properties instead.
# FACETS and AFFINE_HULL.
# Use corresponding input properties instead.
# https://forum.polymake.org/viewtopic.php?f=8&t=545
return polymake.new_object(polymake_class,
INEQUALITIES=self.inequalities_list(),
EQUATIONS=self.equations_list())
else:
return polymake.new_object(polymake_class,
FACETS=self.inequalities_list(),
AFFINE_HULL=self.equations_list(),
VERTICES= [ [1] + v for v in self.vertices_list() ] \
+ [ [0] + r for r in self.rays_list() ],
LINEALITY_SPACE=[ [0] + l for l in self.lines_list() ])

verts_and_rays = [[1] + v for v in self.vertices_list()]
verts_and_rays += [[0] + r for r in self.rays_list()]
return polymake.new_object(polymake_class,
FACETS=self.inequalities_list(),
AFFINE_HULL=self.equations_list(),
VERTICES=verts_and_rays,
LINEALITY_SPACE=[[0] + l for l in self.lines_list()])
2 changes: 1 addition & 1 deletion src/sage/geometry/polyhedron/base3.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def _test_combinatorial_polyhedron(self, tester=None, **options):
tester.info("\n Running the test suite of self.combinatorial_polyhedron()")
TestSuite(self.combinatorial_polyhedron()).run(verbose=tester._verbose,
prefix=tester._prefix+" ")
tester.info(tester._prefix+" ", newline = False)
tester.info(tester._prefix + " ", newline=False)

def face_generator(self, face_dimension=None, algorithm=None, **kwds):
r"""
Expand Down
5 changes: 2 additions & 3 deletions src/sage/geometry/pseudolines.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@

class PseudolineArrangement:

def __init__(self, seq, encoding = "auto"):
def __init__(self, seq, encoding="auto"):
r"""
Creates an arrangement of pseudolines.
Expand Down Expand Up @@ -463,8 +463,7 @@ def show(self, **args):
L += text(str(i), (0, l[0][1]+.3), horizontal_alignment="right")
L += text(str(i), (x+2, l[-1][1]+.3), horizontal_alignment="left")

return L.show(axes = False, **args)

return L.show(axes=False, **args)

def __repr__(self):
r"""
Expand Down
18 changes: 7 additions & 11 deletions src/sage/geometry/triangulation/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,23 +193,19 @@ def triangulation_render_3d(triangulation, **kwds):
exterior_triangs = [l for l in all_triangs if l not in interior_triangs]

plot_interior_triangs = \
sum([ polygon3d([coord[t[0]], coord[t[1]], coord[t[2]]],
texture = triang_int, **kwds)
for t in interior_triangs ])
sum([polygon3d([coord[t[0]], coord[t[1]], coord[t[2]]],
texture=triang_int, **kwds)
for t in interior_triangs])
plot_exterior_triangs = \
sum([ polygon3d([coord[t[0]], coord[t[1]], coord[t[2]]],
texture = triang_ext, **kwds)
for t in exterior_triangs ])
sum([polygon3d([coord[t[0]], coord[t[1]], coord[t[2]]],
texture=triang_ext, **kwds)
for t in exterior_triangs])

return \
plot_points + \
return plot_points + \
plot_interior_lines + plot_exterior_lines + \
plot_interior_triangs + plot_exterior_triangs





########################################################################
class Triangulation(Element):
"""
Expand Down
5 changes: 2 additions & 3 deletions src/sage/geometry/triangulation/point_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1377,8 +1377,7 @@ def secondary_polytope(self):
#change the next line to only take the regular triangulations,
#since they are the vertices of the secondary polytope anyway.
l = self.triangulations_list()
return Polyhedron(vertices = [x.gkz_phi() for x in l])

return Polyhedron(vertices=[x.gkz_phi() for x in l])

def circuits_support(self):
r"""
Expand Down Expand Up @@ -2019,7 +2018,7 @@ def facets_of_simplex(simplex):

# construct the initial simplex
if point_order_is_given:
simplices = [frozenset(self.contained_simplex(large=False, point_order = point_order))]
simplices = [frozenset(self.contained_simplex(large=False, point_order=point_order))]
else:
simplices = [frozenset(self.contained_simplex(large=True))]
for s in simplices[0]:
Expand Down
4 changes: 1 addition & 3 deletions src/sage/manifolds/differentiable/curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,11 +965,9 @@ def plot(self, chart=None, ambient_coords=None, mapping=None, prange=None,

return self._graphics(plot_curve, ambient_coords,
thickness=thickness,
aspect_ratio=aspect_ratio, color= color,
aspect_ratio=aspect_ratio, color=color,
style=style, label_axes=label_axes)



def _graphics(self, plot_curve, ambient_coords, thickness=1,
aspect_ratio='automatic', color='red', style='-',
label_axes=True):
Expand Down
8 changes: 4 additions & 4 deletions src/sage/manifolds/differentiable/degenerate_submanifold.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,14 +1200,14 @@ def shape_operator(self, screen=None):
T = T.along(im)
except ValueError:
pass
T.set_name("A^*", latex_name = r'A^\ast')
T.set_name("A^*", latex_name=r'A^\ast')
A = TangentTensor(T, im)
self._shape_operator[screen._name] = A
return A

def gauss_curvature(self, screen=None):
r"""
Gauss curvature is the product of all eigenfunctions of the shape operator.
Gauss curvature is the product of all eigenfunctions of the shape operator.
INPUT:
Expand Down Expand Up @@ -1245,8 +1245,8 @@ def gauss_curvature(self, screen=None):
"""
if self._ambient._dim-self._dim != 1:
raise ValueError("'gauss_curvature' is defined"+
" only for hypersurfaces.")
raise ValueError("'gauss_curvature' is defined"
" only for hypersurfaces.")
if screen is None:
screen = self.default_screen()
if screen._name not in self._gauss_curvature:
Expand Down
4 changes: 1 addition & 3 deletions src/sage/manifolds/differentiable/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,15 +1220,13 @@ def weyl(self, name=None, latex_name=None):
3-dimensional differentiable manifold H^3
sage: C == 0
True
"""
if self._weyl is None:
n = self._ambient_domain.dimension()
if n < 3:
raise ValueError("the Weyl tensor is not defined for a " +
"manifold of dimension n <= 2")
delta = self._domain.tangent_identity_field(dest_map=
self._vmodule._dest_map)
delta = self._domain.tangent_identity_field(dest_map=self._vmodule._dest_map)
riem = self.riemann()
ric = self.ricci()
rscal = self.ricci_scalar()
Expand Down

0 comments on commit 8ef4334

Please sign in to comment.