Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
examples and pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
jplab committed Oct 6, 2020
1 parent 26c03d1 commit bed13a6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
26 changes: 13 additions & 13 deletions src/sage/geometry/polyhedron/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ def n_Vrepresentation(self):

def Vrep_generator(self):
"""
Returns an iterator over the objects of the V-representation
Return an iterator over the objects of the V-representation
(vertices, rays, and lines).
EXAMPLES::
Expand Down Expand Up @@ -4230,7 +4230,7 @@ def _triangulate_normaliz(self):

def triangulate(self, engine='auto', connected=True, fine=False, regular=None, star=None):
r"""
Returns a triangulation of the polytope.
Return a triangulation of the polytope.
INPUT:
Expand Down Expand Up @@ -4746,7 +4746,7 @@ def product(self, other):
if self.n_vertices() == 0 or other.n_vertices() == 0:
# In this case we obtain the empty polyhedron.
# There is not vertex to attach the rays or lines to.
# By our convenction, in this case the polyhedron shall also not have rays or lines.
# By our convention, in this case the polyhedron shall also not have rays or lines.
rays = ()
lines = ()

Expand Down Expand Up @@ -5111,7 +5111,7 @@ def _test_dilation(self, tester=None, **options):
# Avoid long time computations.
return

# Some sanity check on the volume (only run for relativly small instances).
# Some sanity check on the volume (only run for relatively small instances).
if self.dim() > -1 and self.is_compact() and self.base_ring().is_exact():
tester.assertEqual(self.dilation(3).volume(measure='induced'), self.volume(measure='induced')*3**self.dim())

Expand Down Expand Up @@ -5263,7 +5263,7 @@ def linear_transformation(self, linear_transf, new_base_ring=None):
if self.is_compact() and self.n_vertices() and self.n_inequalities():
homogeneous_basis = matrix(R, ( [1] + list(v) for v in self.an_affine_basis() )).transpose()

# To convert first to a list and then to a matrix seems to be necesarry to obtain a meaningful error,
# To convert first to a list and then to a matrix seems to be necessary to obtain a meaningful error,
# in case the number of columns doesn't match the dimension.
new_homogeneous_basis = matrix(list( [1] + list(linear_transf*vector(R, v)) for v in self.an_affine_basis()) ).transpose()

Expand Down Expand Up @@ -6193,7 +6193,7 @@ def _test_lawrence(self, tester=None, **options):
with warnings.catch_warnings():
warnings.simplefilter("error")
try:
# Implicitely checks :trac:`30328`.
# Implicitly checks :trac:`30328`.
R = self.lawrence_extension(2.0*v - self.center())
tester.assertEqual(self.dim() + 1, R.dim())
tester.assertEqual(self.n_vertices() + 2, R.n_vertices())
Expand All @@ -6203,7 +6203,7 @@ def _test_lawrence(self, tester=None, **options):
# Data is numerically complicated.
pass
except ValueError as err:
if not "Numerical inconsistency" in err.args[0]:
if "Numerical inconsistency" not in err.args[0]:
raise err

if self.n_vertices() >= 12 or (self.base_ring() not in (ZZ, QQ) and self.backend() == 'field'):
Expand Down Expand Up @@ -6877,7 +6877,7 @@ def f_vector(self):
OUTPUT:
Returns a vector whose `i`-th entry is the number of
Return a vector whose `i`-th entry is the number of
`i-2`-dimensional faces of the polytope.
.. NOTE::
Expand Down Expand Up @@ -7286,7 +7286,7 @@ def polar(self, in_affine_span=False):
else:
# Transform the equations such that the normals are pairwise orthogonal.
t_eqns = list(t_eqns)
for i,h in enumerate(t_eqns):
for i, h in enumerate(t_eqns):
for h1 in t_eqns[:i]:
a = h[1:]*h1[1:]
if a:
Expand Down Expand Up @@ -7344,7 +7344,7 @@ def is_self_dual(self):

def pyramid(self):
"""
Returns a polyhedron that is a pyramid over the original.
Return a polyhedron that is a pyramid over the original.
EXAMPLES::
Expand Down Expand Up @@ -7685,7 +7685,7 @@ def schlegel_projection(self, facet=None, position=None):
- ``position`` -- a positive number. Determines a relative distance
from the barycenter of ``facet``. A value close to 0 will place the
projection point close to the facet and a large value further away.
projection point close to the facet and a large value further away.
Default is `1`. If the given value is too large, an error is returned.
OUTPUT:
Expand Down Expand Up @@ -9834,7 +9834,7 @@ def affine_hull_projection(self, as_affine_map=False, orthogonal=False, orthonor
Each polyhedron is contained in some smallest affine subspace
(possibly the entire ambient space) -- its affine hull.
We provide a projection of the ambient
space of the polyhedron to Euclidian space of dimension of the
space of the polyhedron to Euclidean space of dimension of the
polyhedron. Then the image of the polyhedron under this
projection (or, depending on the parameter ``as_affine_map``,
the projection itself) is returned.
Expand Down Expand Up @@ -10168,7 +10168,7 @@ def affine_hull_projection(self, as_affine_map=False, orthogonal=False, orthonor

translate_vector = vector(A.base_ring(), affine_basis[0])

# Note the order. We compute ``A*self`` and then substract the translation vector.
# Note the order. We compute ``A*self`` and then subtract the translation vector.
# ``A*self`` uses the incidence matrix and we avoid recomputation.
# Also, if the new base ring is ``AA``, we want to avoid computing the incidence matrix in that ring.

Expand Down
18 changes: 17 additions & 1 deletion src/sage/geometry/polyhedron/face.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,14 +760,30 @@ def normal_cone(self, direction='outer'):
def stacking_locus(self):
"""
Return the polyhedron containing the points that sees every facet
containing ``self``.
containing ``self``.
OUTPUT:
A polyhedron.
EXAMPLES::
sage: cp = polytopes.cross_polytope(4)
sage: facet = cp.facets()[0]
sage: facet.stacking_locus().vertices()
(A vertex at (1/2, 1/2, 1/2, 1/2),
A vertex at (1, 0, 0, 0),
A vertex at (0, 0, 0, 1),
A vertex at (0, 0, 1, 0),
A vertex at (0, 1, 0, 0))
sage: face = cp.faces(2)[0]
sage: face.stacking_locus().vertices()
(A vertex at (0, 1, 0, 0),
A vertex at (0, 0, 1, 0),
A vertex at (1, 0, 0, 0),
A vertex at (1, 1, 1, 0),
A vertex at (1/2, 1/2, 1/2, 1/2),
A vertex at (1/2, 1/2, 1/2, -1/2))
"""
# Taking all facets that contain the face
if self.dim() == self.polyhedron().dim() - 1:
Expand Down
12 changes: 6 additions & 6 deletions src/sage/geometry/polyhedron/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def __call__(self, x):
# The intersection of the segment with the facet
preimage = (segment & self.facet).vertices()[0].vector()
# The transformation matrix acts on the right:
return preimage*self.A + self.b
return preimage*self.A + self.b

#########################################################################

Expand Down Expand Up @@ -471,7 +471,7 @@ def schlegel(self, facet=None, position=None):
- ``position`` -- a positive number. Determines a relative distance
from the barycenter of ``facet``. A value close to 0 will place the
projection point close to the facet and a large value further away.
projection point close to the facet and a large value further away.
Default is `1`. If the given value is too large, an error is returned.
EXAMPLES::
Expand Down Expand Up @@ -1171,7 +1171,7 @@ def tikz(self, view=[0, 0, 1], angle=0, scale=1,
the desired view angle is found, click on the information icon in
the lower right-hand corner and select *Get Viewpoint*. This will
copy a string of the form '[x,y,z],angle' to your local clipboard.
Go back to Sage and type ``Img = P.projection().tikz([x,y,z],angle)``.
Go back to Sage and type ``Img = P.projection().tikz([x,y,z],angle)``.
The inputs ``view`` and ``angle`` can also be obtained from the
viewer Jmol::
Expand Down Expand Up @@ -1348,7 +1348,7 @@ def _tikz_2d(self, scale, edge_color, facet_color, opacity, vertex_color, axis):
# Gives the reproduction information
from sage.env import SAGE_VERSION
tikz_pic += "%% This TikZ-picture was produce with Sagemath version {}\n".format(SAGE_VERSION)
tikz_pic += "%% with the command: ._tikz_2d and parameters:\n"
tikz_pic += "%% with the command: ._tikz_2d and parameters:\n"
tikz_pic += "%% scale = {}\n".format(scale)
tikz_pic += "%% edge_color = {}\n".format(edge_color)
tikz_pic += "%% facet_color = {}\n".format(facet_color)
Expand Down Expand Up @@ -1493,7 +1493,7 @@ def _tikz_2d_in_3d(self, view, angle, scale, edge_color, facet_color,
# Gives the reproduction information
from sage.env import SAGE_VERSION
tikz_pic += "%% This TikZ-picture was produce with Sagemath version {}\n".format(SAGE_VERSION)
tikz_pic += "%% with the command: ._tikz_2d_in_3d and parameters:\n"
tikz_pic += "%% with the command: ._tikz_2d_in_3d and parameters:\n"
tikz_pic += "%% view = {}\n".format(view)
tikz_pic += "%% angle = {}\n".format(angle)
tikz_pic += "%% scale = {}\n".format(scale)
Expand Down Expand Up @@ -1687,7 +1687,7 @@ def _tikz_3d_in_3d(self, view, angle, scale, edge_color,
# Gives the reproduction information
from sage.env import SAGE_VERSION
tikz_pic += "%% This TikZ-picture was produce with Sagemath version {}\n".format(SAGE_VERSION)
tikz_pic += "%% with the command: ._tikz_3d_in_3d and parameters:\n"
tikz_pic += "%% with the command: ._tikz_3d_in_3d and parameters:\n"
tikz_pic += "%% view = {}\n".format(view)
tikz_pic += "%% angle = {}\n".format(angle)
tikz_pic += "%% scale = {}\n".format(scale)
Expand Down

0 comments on commit bed13a6

Please sign in to comment.