Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some ruff fixes and error links in the graphs folder #36899

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/sage/graphs/base/c_graph.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -624,8 +624,8 @@ cdef class CGraph:

OUTPUT:

- Raise a ``NotImplementedError``. This method is not implemented in
this base class. A child class should provide a suitable
- Raise a :class:`NotImplementedError`. This method is not implemented
in this base class. A child class should provide a suitable
implementation.

.. SEEALSO::
Expand Down Expand Up @@ -1267,7 +1267,7 @@ cdef class CGraph:

OUTPUT:

- Raise ``NotImplementedError``. This method is not implemented at
- Raise :class:`NotImplementedError`. This method is not implemented at
the :class:`CGraph` level. A child class should provide a suitable
implementation.

Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/base/graph_backends.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This module implements :class:`GenericGraphBackend` (the base class for
backends).

Any graph backend must redefine the following methods (for which
:class:`GenericGraphBackend` raises a ``NotImplementedError``)
:class:`GenericGraphBackend` raises a :class:`NotImplementedError`)

.. csv-table::
:class: contentstable
Expand Down
1 change: 0 additions & 1 deletion src/sage/graphs/bipartite_graph.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# autopep8: off
# -*- coding: utf-8 -*-
r"""
Bipartite graphs

Expand Down
7 changes: 4 additions & 3 deletions src/sage/graphs/bliss.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,10 @@ cpdef canonical_form(G, partition=None, return_graph=False, use_edge_labels=True
canonical graph of ``G`` or its set of edges

- ``use_edge_labels`` -- boolean (default: ``True``); whether to consider
edge labels. The edge labels are assumed to be hashable and sortable. If
this is not the case (ie a ``TypeError`` is raised), the algorithm will
consider the string representations of the labels instead of the labels.
edge labels. The edge labels are assumed to be hashable and
sortable. If this is not the case (ie a :class:`TypeError` is
raised), the algorithm will consider the string representations
of the labels instead of the labels.

- ``certificate`` -- boolean (default: ``False``); when set to ``True``,
returns the labeling of G into a canonical graph
Expand Down
10 changes: 5 additions & 5 deletions src/sage/graphs/digraph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Directed graphs

Expand Down Expand Up @@ -3187,9 +3186,9 @@ def topological_sort(self, implementation="default"):
"""
Return a topological sort of the digraph if it is acyclic.

If the digraph contains a directed cycle, a ``TypeError`` is raised. As
topological sorts are not necessarily unique, different implementations
may yield different results.
If the digraph contains a directed cycle, a :class:`TypeError`
is raised. As topological sorts are not necessarily unique,
different implementations may yield different results.

A topological sort is an ordering of the vertices of the digraph such
that each vertex comes before all of its successors. That is, if `u`
Expand Down Expand Up @@ -3269,7 +3268,8 @@ def topological_sort_generator(self):
Return an iterator over all topological sorts of the digraph if
it is acyclic.

If the digraph contains a directed cycle, a ``TypeError`` is raised.
If the digraph contains a directed cycle, a :class:`TypeError`
is raised.

A topological sort is an ordering of the vertices of the digraph such
that each vertex comes before all of its successors. That is, if u comes
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/digraph_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
from sage.graphs.graph import Graph


class DiGraphGenerators():
class DiGraphGenerators:
r"""
A class consisting of constructors for several common digraphs,
including orderly generation of isomorphism class representatives.
Expand Down
1 change: 0 additions & 1 deletion src/sage/graphs/domination.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Domination

Expand Down
3 changes: 1 addition & 2 deletions src/sage/graphs/generators/basic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Basic graphs

Expand Down Expand Up @@ -400,7 +399,7 @@ def CompleteGraph(n):
G.set_pos({0: (0, 0)})
else:
G._circle_embedding(list(range(n)), angle=pi/2)
G.add_edges(((i, j) for i in range(n) for j in range(i + 1, n)))
G.add_edges((i, j) for i in range(n) for j in range(i + 1, n))
return G

def CorrelationGraph(seqs, alpha, include_anticorrelation):
Expand Down
1 change: 0 additions & 1 deletion src/sage/graphs/generators/chessboard.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Chessboard graphs

Expand Down
5 changes: 2 additions & 3 deletions src/sage/graphs/generators/degree_sequence.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Graphs with a given degree sequence

Expand Down Expand Up @@ -98,8 +97,8 @@ def DegreeSequenceBipartite(s1, s2):
True

Some sequences being incompatible if, for example, their sums are different,
the functions raises a ``ValueError`` when no graph corresponding to the
degree sequences exists::
the functions raises a :class:`ValueError` when no graph corresponding
to the degree sequences exists::

sage: g = graphs.DegreeSequenceBipartite([2,2,2,2,1],[5,5]) # needs sage.combinat sage.modules
Traceback (most recent call last):
Expand Down
7 changes: 3 additions & 4 deletions src/sage/graphs/generators/families.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Various families of graphs

Expand Down Expand Up @@ -594,7 +593,7 @@ def BarbellGraph(n1, n2):

OUTPUT:

A barbell graph of order ``2*n1 + n2``. A ``ValueError`` is
A barbell graph of order ``2*n1 + n2``. A :class:`ValueError` is
returned if ``n1 < 2`` or ``n2 < 0``.

PLOTTING:
Expand Down Expand Up @@ -929,7 +928,7 @@ def BubbleSortGraph(n):
OUTPUT:

The bubble sort graph `B(n)` on `n` symbols. If `n < 1`, a
``ValueError`` is returned.
:class:`ValueError` is returned.

EXAMPLES::

Expand Down Expand Up @@ -2714,7 +2713,7 @@ def SwitchedSquaredSkewHadamardMatrixGraph(n):
G = SquaredSkewHadamardMatrixGraph(n).complement()
G.add_vertex((4 * n - 1)**2)
G.seidel_switching(list(range((4 * n - 1) * (2 * n - 1))))
G.name("switch skewhad^2+*_" + str((n)))
G.name("switch skewhad^2+*_" + str(n))
return G


Expand Down
1 change: 0 additions & 1 deletion src/sage/graphs/generators/intersection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Intersection graphs

Expand Down
1 change: 0 additions & 1 deletion src/sage/graphs/generators/platonic_solids.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
1-skeletons of Platonic solids

Expand Down
1 change: 0 additions & 1 deletion src/sage/graphs/generators/random.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Random graphs

Expand Down
1 change: 0 additions & 1 deletion src/sage/graphs/generators/smallgraphs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Various small graphs

Expand Down
1 change: 0 additions & 1 deletion src/sage/graphs/generators/world_map.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Graphs from the World Map

Expand Down
17 changes: 8 additions & 9 deletions src/sage/graphs/generic_graph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Generic graphs (common to directed/undirected)

Expand Down Expand Up @@ -2933,8 +2932,8 @@ def _check_embedding_validity(self, embedding=None, boolean=True):
``_embedding``

- ``boolean`` -- boolean (default: ``True``); -- whether to return a
boolean answer or raise a ``ValueError`` exception if the embedding is
invalid
boolean answer or raise a :class:`ValueError` exception
if the embedding is invalid

EXAMPLES::

Expand Down Expand Up @@ -3443,8 +3442,8 @@ def allow_multiple_edges(self, new, check=True, keep_label='any'):
.. WARNING::

``'min'`` and ``'max'`` only works if the labels can be compared. A
``TypeError`` might be raised when working with non-comparable
objects in Python 3.
:class:`TypeError` might be raised when working with non-comparable
objects.

EXAMPLES:

Expand Down Expand Up @@ -4092,7 +4091,7 @@ def density(self):
if n < 2:
return Rational(0)
if self._directed:
return Rational(self.size()) / Rational((n ** 2 - n))
return Rational(self.size()) / Rational(n ** 2 - n)
return Rational(self.size()) / Rational((n ** 2 - n) / 2)

def is_bipartite(self, certificate=False):
Expand Down Expand Up @@ -18894,8 +18893,8 @@ def to_simple(self, to_undirected=True, keep_label='any', immutable=None):
.. WARNING::

``'min'`` and ``'max'`` only works if the labels can be compared. A
``TypeError`` might be raised when working with non-comparable
objects in Python 3.
:class:`TypeError` might be raised when working with non-comparable
objects.

- ``immutable`` -- boolean (default: ``Non``); whether to create a
mutable/immutable copy. ``immutable=None`` (default) means that the
Expand Down Expand Up @@ -25341,7 +25340,7 @@ def graph_isom_equivalent_non_edge_labeled_graph(g, partition=None, standard_lab
for el, part in edge_partition:
# The multiplicity of a label is the number of edges from u to v
# it represents
m = sum((y[1] for y in el))
m = sum(y[1] for y in el)
if m in tmp:
tmp[m].append(part)
else:
Expand Down
5 changes: 2 additions & 3 deletions src/sage/graphs/graph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Undirected graphs

Expand Down Expand Up @@ -3285,8 +3284,8 @@ def bounded_outdegree_orientation(self, bound, solver=None, verbose=False,

OUTPUT:

A DiGraph representing the orientation if it exists. A ``ValueError``
exception is raised otherwise.
A DiGraph representing the orientation if it exists.
A :class:`ValueError` exception is raised otherwise.

ALGORITHM:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Modular Decomposition

Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/graph_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ def wrap_name(x):
from . import graph


class GraphGenerators():
class GraphGenerators:
r"""
A class consisting of constructors for several common graphs, as well as
orderly generation of isomorphism class representatives. See the
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/graph_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@
for u in D:
if len(set(D[u])) != len(D[u]):
if multiedges is False:
v = next((v for v in D[u] if D[u].count(v) > 1))
v = next(v for v in D[u] if D[u].count(v) > 1)

Check warning on line 562 in src/sage/graphs/graph_input.py

View check run for this annotation

Codecov / codecov/patch

src/sage/graphs/graph_input.py#L562

Added line #L562 was not covered by tests
raise ValueError("non-multigraph got several edges (%s, %s)" % (u, v))
multiedges = True
break
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/graph_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def set_option(self, option_name, option_value=None):

- ``option_name`` -- a string for a latex option contained in the list
``sage.graphs.graph_latex.GraphLatex.__graphlatex_options``.
A ``ValueError`` is raised if the option is not allowed.
A :class:`ValueError` is raised if the option is not allowed.

- ``option_value`` -- a value for the option. If omitted, or set to
``None``, the option will use the default value.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/hypergraph_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"""


class HypergraphGenerators():
class HypergraphGenerators:
r"""
A class consisting of constructors for common hypergraphs.
"""
Expand Down
1 change: 0 additions & 1 deletion src/sage/graphs/lovasz_theta.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
r"""
Lovász theta-function of graphs

Expand Down
4 changes: 2 additions & 2 deletions src/sage/graphs/pq_trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def set_contiguous(self, v):

In any case, the sets containing ``v`` are contiguous when this
function ends. If there is no possibility of doing so, the function
raises a ``ValueError`` exception.
raises a :class:`ValueError` exception.

EXAMPLES:

Expand Down Expand Up @@ -837,7 +837,7 @@ def set_contiguous(self, v):

In any case, the sets containing ``v`` are contiguous when this
function ends. If there is no possibility of doing so, the function
raises a ``ValueError`` exception.
raises a :class:`ValueError` exception.

EXAMPLES:

Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/schnyder.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def _compute_coordinates(g, x):
g.set_pos(coordinates) # Setting _pos attribute to store coordinates


class TreeNode():
class TreeNode:
"""
A class to represent each node in the trees used by ``_realizer`` and
``_compute_coordinates`` when finding a planar geometric embedding in
Expand Down
4 changes: 2 additions & 2 deletions src/sage/graphs/tutte_polynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def edge_multiplicities(G):
########


class Ear():
class Ear:
r"""
An ear is a sequence of vertices

Expand Down Expand Up @@ -372,7 +372,7 @@ def removed_from(self, G):
##################


class EdgeSelection():
class EdgeSelection:
pass


Expand Down
Loading