Skip to content

Commit

Permalink
sagemathgh-36903: ruff UP details and links to errors in doc in geome…
Browse files Browse the repository at this point in the history
…try folder

    
This is fixing a few ruff details (code UP) and adding some links to
errors in the doc, in the `geometry` folder.

### 📝 Checklist

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
    
URL: sagemath#36903
Reported by: Frédéric Chapoton
Reviewer(s): Matthias Köppe
  • Loading branch information
Release Manager committed Dec 21, 2023
2 parents 593a9bb + 7d7e5e0 commit 803f602
Show file tree
Hide file tree
Showing 27 changed files with 78 additions and 86 deletions.
25 changes: 12 additions & 13 deletions src/sage/geometry/cone.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Convex rational polyhedral cones
Expand Down Expand Up @@ -554,7 +553,7 @@ def _ambient_space_point(body, data):
An integral, rational, real algebraic, or numeric point of the
ambient space of ``body`` is returned if ``data`` were
successfully interpreted in such a way. A ``TypeError`` is raised
successfully interpreted in such a way. A :class:`TypeError` is raised
otherwise.
TESTS::
Expand Down Expand Up @@ -1664,7 +1663,7 @@ def _contains(self, point, region='whole cone'):
otherwise, in particular when ``point`` is incompatible with
the ambient space.
A ``ValueError`` is raised if ``region`` is not one of the
A :class:`ValueError` is raised if ``region`` is not one of the
three allowed values.
TESTS::
Expand Down Expand Up @@ -2340,8 +2339,8 @@ def embed(self, cone):
or
:meth:`~sage.geometry.cone.ConvexRationalPolyhedralCone.facet_of`. The
cone returned by this method will have ``self`` as ambient. If ``cone``
does not represent a valid cone of ``self``, ``ValueError`` exception
is raised.
does not represent a valid cone of ``self``, :class:`ValueError`
exception is raised.
.. NOTE::
Expand Down Expand Up @@ -3017,8 +3016,8 @@ def intersection(self, other):
- :class:`cone <ConvexRationalPolyhedralCone>`.
Raises ``ValueError`` if the ambient space dimensions are not
compatible.
This raises :class:`ValueError` if the ambient space dimensions
are not compatible.
EXAMPLES::
Expand Down Expand Up @@ -5349,7 +5348,7 @@ def random_element(self, ring=ZZ):
Either a lattice element or vector contained in both this cone
and its ambient vector space. If ``ring`` is ``ZZ``, a lattice
element is returned; otherwise a vector is returned. If ``ring``
is neither ``ZZ`` nor ``QQ``, then a ``NotImplementedError`` is
is neither ``ZZ`` nor ``QQ``, then a :class:`NotImplementedError` is
raised.
EXAMPLES:
Expand Down Expand Up @@ -6267,7 +6266,7 @@ def random_cone(lattice=None, min_ambient_dim=0, max_ambient_dim=None,
A new, randomly generated cone.
A ``ValueError`` will be thrown under the following conditions:
A :class:`ValueError` will be thrown under the following conditions:
* Any of ``min_ambient_dim``, ``max_ambient_dim``, ``min_rays``, or
``max_rays`` are negative.
Expand Down Expand Up @@ -6425,7 +6424,7 @@ def random_cone(lattice=None, min_ambient_dim=0, max_ambient_dim=None,
provided.
If the user requests too many rays in zero, one, or two dimensions,
a ``ValueError`` is thrown::
a :class:`ValueError` is thrown::
sage: random_cone(max_ambient_dim=0, min_rays=1)
Traceback (most recent call last):
Expand Down Expand Up @@ -6513,7 +6512,7 @@ def random_cone(lattice=None, min_ambient_dim=0, max_ambient_dim=None,
sage: random_cone(lattice=L, strictly_convex=True)
0-d cone in 0-d lattice L
A ``ValueError`` is thrown if a non-solid cone is requested in a
A :class:`ValueError` is thrown if a non-solid cone is requested in a
zero-dimensional lattice::
sage: L = ToricLattice(0)
Expand All @@ -6527,7 +6526,7 @@ def random_cone(lattice=None, min_ambient_dim=0, max_ambient_dim=None,
...
ValueError: all cones are solid when max_ambient_dim is zero.
A ``ValueError`` is thrown if a solid cone is requested but the
A :class:`ValueError` is thrown if a solid cone is requested but the
maximum number of rays is too few::
sage: random_cone(min_ambient_dim=4, max_rays=3, solid=True)
Expand All @@ -6542,7 +6541,7 @@ def random_cone(lattice=None, min_ambient_dim=0, max_ambient_dim=None,
ValueError: max_rays must be at least 5 for a solid cone in this
lattice.
A ``ValueError`` is thrown if a non-solid cone is requested but
A :class:`ValueError` is thrown if a non-solid cone is requested but
``min_rays`` guarantees a solid cone::
sage: random_cone(max_ambient_dim=4, min_rays=10, solid=False)
Expand Down
10 changes: 5 additions & 5 deletions src/sage/geometry/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -1956,7 +1956,7 @@ def cone_containing(self, *points):
We think of the origin as of the smallest cone containing no rays
at all. If there is no ray in ``self`` that contains all ``rays``,
a ``ValueError`` exception will be raised.
a :class:`ValueError` exception will be raised.
EXAMPLES::
Expand Down Expand Up @@ -2352,8 +2352,8 @@ def embed(self, cone):
or
:meth:`~sage.geometry.cone.ConvexRationalPolyhedralCone.facet_of`. The
cone returned by this method will have ``self`` as ambient. If ``cone``
does not represent a valid cone of ``self``, ``ValueError`` exception
is raised.
does not represent a valid cone of ``self``, :class:`ValueError`
exception is raised.
.. NOTE::
Expand Down Expand Up @@ -3504,8 +3504,8 @@ def complex(self, base_ring=ZZ, extended=False):
OUTPUT:
The complex associated to the fan as a :class:`ChainComplex
<sage.homology.chain_complex.ChainComplex>`. Raises a
``ValueError`` if the extended complex is requested for a
<sage.homology.chain_complex.ChainComplex>`. This raises a
:class:`ValueError` if the extended complex is requested for a
non-complete fan.
EXAMPLES::
Expand Down
20 changes: 10 additions & 10 deletions src/sage/geometry/fan_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,8 @@ def _ray_index_map(self):
domain fan is mapped to the origin. If it is `j`, then the `i`-th ray
of the domain fan is mapped onto the `j`-th ray of the codomain fan.
If there is a ray in the domain fan which is mapped into the relative
interior of a higher dimensional cone, a ``ValueError`` exception is
raised.
interior of a higher dimensional cone, a :class:`ValueError`
exception is raised.
.. NOTE::
Expand Down Expand Up @@ -601,8 +601,8 @@ def _subdivide_domain_fan(self, check, verbose):
OUTPUT:
- none, but the domain fan of self is replaced with its minimal
refinement, if possible. Otherwise a ``ValueError`` exception is
raised.
refinement, if possible. Otherwise a :class:`ValueError`
exception is raised.
TESTS::
Expand Down Expand Up @@ -763,11 +763,11 @@ def _subdivide_domain_fan(self, check, verbose):

def _support_error(self):
r"""
Raise a ``ValueError`` exception due to support incompatibility.
Raise a :class:`ValueError` exception due to support incompatibility.
OUTPUT:
- none, a ``ValueError`` exception is raised.
- none, a :class:`ValueError` exception is raised.
TESTS:
Expand Down Expand Up @@ -806,10 +806,10 @@ def _validate(self):
OUTPUT:
- none, but a ``ValueError`` exception is raised if there is a cone of
the domain fan of ``self`` which is not completely contained in a
single cone of the codomain fan of ``self``, or if one of these fans
does not sit in the appropriate lattice.
- none, but a :class:`ValueError` exception is raised if there is
a cone of the domain fan of ``self`` which is not completely
contained in a single cone of the codomain fan of ``self``,
or if one of these fans does not sit in the appropriate lattice.
EXAMPLES::
Expand Down
3 changes: 1 addition & 2 deletions src/sage/geometry/hyperbolic_space/hyperbolic_coercion.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
"""
Coercion Maps Between Hyperbolic Plane Models
Expand Down Expand Up @@ -82,7 +81,7 @@ def _call_(self, x):
"""
C = self.codomain()
if not C.is_bounded() and self.domain().is_bounded() and x.is_boundary():
msg = u"boundary points are not implemented for the {}"
msg = "boundary points are not implemented for the {}"
raise NotImplementedError(msg.format(C.name()))

y = self.image_coordinates(x.coordinates())
Expand Down
9 changes: 4 additions & 5 deletions src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Hyperbolic Geodesics
Expand Down Expand Up @@ -622,7 +621,7 @@ def is_parallel(self, other):
def ideal_endpoints(self):
r"""
Return the ideal endpoints in bounded models. Raise a
``NotImplementedError`` in models that are not bounded.
:class:`NotImplementedError` in models that are not bounded.
EXAMPLES::
Expand Down Expand Up @@ -660,7 +659,7 @@ def ideal_endpoints(self):
def complete(self):
r"""
Return the geodesic with ideal endpoints in bounded models. Raise a
``NotImplementedError`` in models that are not bounded.
:class:`NotImplementedError` in models that are not bounded.
In the following examples we represent complete geodesics by a dashed
line.
Expand Down Expand Up @@ -817,7 +816,7 @@ def common_perpendicula(self, other):
r"""
Return the unique hyperbolic geodesic perpendicular to two given
geodesics, if such a geodesic exists. If none exists, raise a
``ValueError``.
:class:`ValueError`.
INPUT:
Expand Down Expand Up @@ -1278,7 +1277,7 @@ def common_perpendicular(self, other):
r"""
Return the unique hyperbolic geodesic perpendicular to ``self``
and ``other``, if such a geodesic exists; otherwise raise a
``ValueError``.
:class:`ValueError`.
INPUT:
Expand Down
1 change: 0 additions & 1 deletion src/sage/geometry/hyperbolic_space/hyperbolic_interface.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Interface to Hyperbolic Models
Expand Down
23 changes: 13 additions & 10 deletions src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Hyperbolic Isometries
Expand Down Expand Up @@ -489,7 +488,7 @@ def classification(self):
def translation_length(self):
r"""
For hyperbolic elements, return the translation length;
otherwise, raise a ``ValueError``.
otherwise, raise a :class:`ValueError`.
EXAMPLES::
Expand All @@ -512,7 +511,7 @@ def translation_length(self):
def axis(self):
r"""
For a hyperbolic isometry, return the axis of the
transformation; otherwise raise a ``ValueError``.
transformation; otherwise raise a :class:`ValueError`.
EXAMPLES::
Expand Down Expand Up @@ -593,7 +592,7 @@ def fixed_geodesic(self):
def repelling_fixed_point(self):
r"""
For a hyperbolic isometry, return the attracting fixed point;
otherwise raise a ``ValueError``.
otherwise raise a :class:`ValueError`.
OUTPUT:
Expand All @@ -612,7 +611,7 @@ def repelling_fixed_point(self):
def attracting_fixed_point(self):
r"""
For a hyperbolic isometry, return the attracting fixed point;
otherwise raise a `ValueError``.
otherwise raise a :class:`ValueError`.
OUTPUT:
Expand Down Expand Up @@ -735,7 +734,7 @@ def classification(self): #UHP
def translation_length(self): #UHP
r"""
For hyperbolic elements, return the translation length;
otherwise, raise a ``ValueError``.
otherwise, raise a :class:`ValueError`.
EXAMPLES::
Expand Down Expand Up @@ -843,9 +842,11 @@ def fixed_point_set(self): # UHP
return self.domain().get_geodesic(*pts)
return pts

def repelling_fixed_point(self): #UHP
def repelling_fixed_point(self): # UHP
r"""
Return the repelling fixed point; otherwise raise a ``ValueError``.
Return the repelling fixed point.
Otherwise, this raises a :class:`ValueError`.
OUTPUT:
Expand All @@ -867,9 +868,11 @@ def repelling_fixed_point(self): #UHP
return self.domain().get_point(infinity)
return self.domain().get_point(v[0] / v[1])

def attracting_fixed_point(self): #UHP
def attracting_fixed_point(self): # UHP
r"""
Return the attracting fixed point; otherwise raise a ``ValueError``.
Return the attracting fixed point.
Otherwise, this raises a :class:`ValueError`.
OUTPUT:
Expand Down
11 changes: 5 additions & 6 deletions src/sage/geometry/hyperbolic_space/hyperbolic_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Hyperbolic Models
Expand Down Expand Up @@ -156,7 +155,7 @@ def _repr_(self): # Abstract
sage: HyperbolicPlane().UHP()
Hyperbolic plane in the Upper Half Plane Model
"""
return u'Hyperbolic plane in the {}'.format(self._name)
return 'Hyperbolic plane in the {}'.format(self._name)

def _element_constructor_(self, x, is_boundary=None, **graphics_options): # Abstract
"""
Expand Down Expand Up @@ -260,7 +259,7 @@ def point_in_model(self, p):
def point_test(self, p): # Abstract
r"""
Test whether a point is in the model. If the point is in the
model, do nothing. Otherwise, raise a ``ValueError``.
model, do nothing. Otherwise, raise a :class:`ValueError`.
EXAMPLES::
Expand Down Expand Up @@ -298,7 +297,7 @@ def boundary_point_in_model(self, p): # Abstract
def bdry_point_test(self, p): # Abstract
r"""
Test whether a point is in the model. If the point is in the
model, do nothing; otherwise raise a ``ValueError``.
model, do nothing; otherwise raise a :class:`ValueError`.
EXAMPLES::
Expand Down Expand Up @@ -340,7 +339,7 @@ def isometry_test(self, A): # Abstract
Test whether an isometry ``A`` is in the model.
If the isometry is in the model, do nothing. Otherwise, raise
a ``ValueError``.
a :class:`ValueError`.
EXAMPLES::
Expand Down Expand Up @@ -1173,7 +1172,7 @@ def __init__(self, space):
# name should really be 'Poincaré Disk Model', but utf8 is not
# accepted by repr
HyperbolicModel.__init__(self, space,
name=u'Poincare Disk Model', short_name="PD",
name='Poincare Disk Model', short_name="PD",
bounded=True, conformal=True, dimension=2,
isometry_group="PU(1, 1)",
isometry_group_is_projective=True)
Expand Down
1 change: 0 additions & 1 deletion src/sage/geometry/hyperbolic_space/hyperbolic_point.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Hyperbolic Points
Expand Down
3 changes: 1 addition & 2 deletions src/sage/geometry/hyperplane_arrangement/arrangement.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Hyperplane Arrangements
Expand Down Expand Up @@ -2723,7 +2722,7 @@ def region_containing_point(self, p):
OUTPUT:
A polyhedron. A ``ValueError`` is raised if the point is not
A polyhedron. A :class:`ValueError` is raised if the point is not
interior to a region, that is, sits on a hyperplane.
EXAMPLES::
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/hyperplane_arrangement/hyperplane.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def orthogonal_projection(self, point):
A vector in the ambient vector space that lies on the
hyperplane.
In finite characteristic, a ``ValueError`` is raised if the
In finite characteristic, a :class:`ValueError` is raised if the
the norm of the hyperplane normal is zero.
EXAMPLES::
Expand Down

0 comments on commit 803f602

Please sign in to comment.