Skip to content

Commit

Permalink
Fix typos detected by the typos tool (#1330)
Browse files Browse the repository at this point in the history
* typos: apply automatic corrections

* typos: apply manual corrections

* typos: run as linter

* typos: apply automatic corrections in releasenotes/

* typos: also check releasenotes content

* Add release notes fragment

* workflows/main: add spell check

* Fix docs build

* typos: upgrade to 1.28

* workflows/main: pin rust to 1.82

* workflows/main: remove spell check

* Use Rust stable again

* Typos: dedicated nox command

* Move typos configuration to pyproject.toml

---------

Co-authored-by: Ivan Carvalho <[email protected]>
Co-authored-by: Ivan Carvalho <[email protected]>
  • Loading branch information
3 people authored Nov 30, 2024
1 parent 5d28053 commit 680789b
Show file tree
Hide file tree
Showing 74 changed files with 184 additions and 166 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- run: pip install -U ruff==0.6.8 black~=24.8
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
components: rustfmt, clippy
- name: Test Build
run: cargo build
- name: Rust Format
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ cargo doc --open
### Type Annotations
If you have added new methods, functions, or classes, and/or changed any
signatures, type anotations for Python are required to be included in a pull
signatures, type annotations for Python are required to be included in a pull
request. Type annotations are added using type
[stub files](https://typing.readthedocs.io/en/latest/source/stubs.html) which
provide type annotations to python tooling which use type annotations. The stub
Expand Down Expand Up @@ -523,7 +523,7 @@ primary exception to this is adding support for new python versions. If a new
python version is released backporting that feature change with that new support
is an acceptable backport.
In rustworkx at least until the 1.0 release we only maintaing a single stable
In rustworkx at least until the 1.0 release we only maintain a single stable
branch at a time for the most recent minor version release.
#### Backporting procedure
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ it just as it would if there was a prebuilt binary available.
> [!NOTE]
> To build from source you will need to ensure you have pip >=19.0.0
installed, which supports PEP-517, or that you have manually installed
`setuptools-rust` prior to running `pip install rustworkx`. If you recieve an
`setuptools-rust` prior to running `pip install rustworkx`. If you receive an
error about `setuptools-rust` not being found you should upgrade pip with
`pip install -U pip` or manually install `setuptools-rust` with
`pip install setuptools-rust` and try again.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/benchmarks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Rustworkx Comparison Benchmarks With Other Libraries
****************************************************

rustworkx is competitive against other popular graph libraries for Python. We compared rustworkx to the igraph, graph-tools and NetworkIt libraries `in a benchmark consisting of four tasks available on Github for reproducibility <https://github.com/mtreinish/retworkx-comparison-benchmarks>`__. We report the results from a machine with an Intel(R) i9-9900K CPU at 3.60GHz with eight cores, 16 theads, and 32GB of RAM avaialble.
rustworkx is competitive against other popular graph libraries for Python. We compared rustworkx to the igraph, graph-tools and NetworkIt libraries `in a benchmark consisting of four tasks available on Github for reproducibility <https://github.com/mtreinish/retworkx-comparison-benchmarks>`__. We report the results from a machine with an Intel(R) i9-9900K CPU at 3.60GHz with eight cores, 16 threads, and 32GB of RAM available.

Graph Creation
==============
Expand Down
4 changes: 2 additions & 2 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ just as it would if there was a prebuilt binary available.

To build from source you will need to ensure you have pip >=19.0.0
installed, which supports PEP-517, or that you have manually installed
setuptools-rust prior to running pip install rustworkx. If you recieve an
setuptools-rust prior to running pip install rustworkx. If you receive an
error about ``setuptools-rust`` not being found you should upgrade pip with
``pip install -U pip`` or manually install ``setuptools-rust`` with:
``pip install setuptools-rust`` and try again.

.. _platform-suppport:
.. _platform-support:

Platform Support
================
Expand Down
4 changes: 2 additions & 2 deletions docs/source/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ New Features

- A new method, :meth:`~rustworkx.PyDiGraph.remove_node_retain_edges`, has been
added to the :class:`~rustworkx.PyDiGraph` class. This method can be used to
remove a node and add edges from its predecesors to its successors.
remove a node and add edges from its predecessors to its successors.
- Two new methods, :meth:`~rustworkx.PyGraph.edge_list` and
:meth:`~rustworkx.PyGraph.weighted_edge_list`, for getting a list of tuples
with the edge source and target (with or without edge weights) have been
Expand All @@ -285,7 +285,7 @@ New Features
edge list file and will read that file and generate a new object from the
contents.
- Two new methods, :meth:`~rustworkx.PyGraph.extend_from_edge_list` and
:meth:`~rustworkx.PyGraoh.extend_from_weighted_edge_list` has been added
:meth:`~rustworkx.PyGraph.extend_from_weighted_edge_list` has been added
to :class:`~rustworkx.PyGraph` and :class:`~rustworkx.PyDiGraph`
(:meth:`~rustworkx.PyDiGraph.extend_from_edge_list` and
:meth:`~rustworkx.PyDiGraph.extend_from_weighted_edge_list`). This method
Expand Down
4 changes: 2 additions & 2 deletions docs/source/tutorial/betweenness_centrality.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ To start we need to generate a graph:
mpl_draw(graph)


Calculate the Betweeness Centrality
-----------------------------------
Calculate the Betweenness Centrality
------------------------------------

The :func:`~rustworkx.betweenness_centrality` function can be used to calculate
the betweenness centrality for each node in the graph.
Expand Down
4 changes: 2 additions & 2 deletions docs/source/tutorial/dags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs. For example:
Above we define a DAG with 6 jobs and dependency relationship between these
jobs. Now if we run the :func:`~rustworkx.topological_sort` function on the
graph it will return a linear order to execute the jobs that will respect
the dependency releationship.
the dependency relationship.

.. jupyter-execute::

Expand Down Expand Up @@ -151,7 +151,7 @@ computation. A quantum circuit is represented graphically like:
The specifics of this circuit aren't important here beyond the fact that
we have 2 qubits, ``q_0`` and ``q_1``, 2 classical bits, ``c_0`` and ``c_1``,
and a series of operations on those qubits with a depedency ordering. The last
and a series of operations on those qubits with a dependency ordering. The last
operation on each qubit is a measurement on ``q_0`` that is stored in ``c_0``
and ``q_1`` that is stored in ``c_1``.

Expand Down
8 changes: 8 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"black~=24.8",
"ruff~=0.6",
"setuptools-rust",
"typos~=1.28",
]

stubs_deps = [
Expand Down Expand Up @@ -45,6 +46,7 @@ def test_with_version(session):
@nox.session(python=["3"])
def lint(session):
black(session)
typos(session)
session.install(*lint_deps)
session.run("ruff", "check", "rustworkx", "retworkx", "setup.py")
session.run("cargo", "fmt", "--all", "--", "--check", external=True)
Expand All @@ -69,6 +71,12 @@ def black(session):
session.install(*[d for d in lint_deps if "black" in d])
session.run("black", "rustworkx", "tests", "retworkx", *session.posargs)

@nox.session(python=["3"])
def typos(session):
session.install(*[d for d in lint_deps if "typos" in d])
session.run("typos", "--exclude", "releasenotes")
session.run("typos", "--no-check-filenames", "releasenotes")

@nox.session(python=["3"])
def stubs(session):
install_rustworkx(session)
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ extend-exclude = ["doc"]
"rustworkx/__init__.py" = ["F405", "F403"]
"*.pyi" = ["F403", "F405", "PYI001", "PYI002"]

[tool.typos.default]
extend-ignore-words-re = [
"[Ss]toer",
]

[tool.cibuildwheel]
manylinux-x86_64-image = "manylinux2014"
manylinux-i686-image = "manylinux2014"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ features:
Added a new method, :meth:`~rustworkx.PyGraph.incident_edge_index_map`, to the
:class:`~rustworkx.PyGraph` and :class:`~rustworkx.PyDiGraph` class. This
method returns a mapping of edge indices for edges incident to a provided node
to the endoint and weight tuple for that edge index. For example:
to the endpoint and weight tuple for that edge index. For example:
.. jupyter-execute::
Expand Down
2 changes: 1 addition & 1 deletion releasenotes/notes/0.11/fix-dispatch-3596ef110cc68338.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ fixes:
- |
Fixed an oversight in the :func:`~rustworkx.union` function where
user-defined values for the ``merge_nodes`` and ``merge_edges`` arguments
were being ingored.
were being ignored.
4 changes: 2 additions & 2 deletions releasenotes/notes/0.11/prepare-0.11-af688e532712c830.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ features:
g = nx.Graph()
g.add_nodes_from([
("A", {"color": "turquoise", "size": "extra large"}),
("B", {"color": "fuschia", "size": "tiny"}),
("B", {"color": "fuchsia", "size": "tiny"}),
])
g.add_edge("A", "B")
rx_graph = rx.networkx_converter(g, keep_attributes=True)
Expand All @@ -65,7 +65,7 @@ features:
will output::
[{'color': 'turquoise', 'size': 'extra large', '__networkx_node__': 'A'}, {'color': 'fuschia', 'size': 'tiny', '__networkx_node__': 'B'}]
[{'color': 'turquoise', 'size': 'extra large', '__networkx_node__': 'A'}, {'color': 'fuchsia', 'size': 'tiny', '__networkx_node__': 'B'}]
WeightedEdgeList[(0, 1, {})]
fixes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fixes:
Fixed an issue with the custom sequence return types,
:class:`~.BFSSuccessors`, :class:`~.NodeIndices`, :class:`~.EdgeList`,
:class:`~.WeightedEdgeList`, :class:`~.EdgeIndices`, and :class:`~.Chains`
where they previosuly were missing certain attributes that prevented them
where they previously were missing certain attributes that prevented them
being used as a sequence for certain built-in functions such as
``reversed()``.
Fixed `#696 <https://github.com/Qiskit/rustworkx/issues/696>`__.
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ prelude: |
This is also the final rustworkx release that supports running with Python
3.7. Starting in the 0.14.0 release Python >= 3.8 will be required to use
rustworkx. This release also increased the minimum suported Rust version for
rustworkx. This release also increased the minimum supported Rust version for
compiling rustworkx and rustworkx-core from source to 1.56.1.
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ upgrade:
token_swapper(&g, mapping, Some(10), Some(4), Some(50));
will now return ``Err(MapNotPossible)`` instead of panicking. If you were using this
funciton before you'll need to handle the result type.
function before you'll need to handle the result type.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ features:
upgrade:
- |
Support for the Linux ppc64le pllatform has changed from tier 3 to tier 4
(as documented in :ref:`platform-suppport`). This is a result of no longer
(as documented in :ref:`platform-support`). This is a result of no longer
being able to run tests during the pre-compiled wheel publishing jobs due
to constraints in the available CI infrastructure. There hopefully
shouldn't be any meaningful impact resulting from this change, but as there
Expand Down
2 changes: 1 addition & 1 deletion releasenotes/notes/0.14/s390x-tier-4-1701a0f044759cd1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
upgrade:
- |
Support for the Linux s390x platform has changed from tier 3 to tier 4 (as
documented in :ref:`platform-suppport`). This is a result of no longer being
documented in :ref:`platform-support`). This is a result of no longer being
able to run tests during the pre-compiled wheel publishing jobs due to
constraints in the available CI infrastructure. There hopefully shouldn't
be any meaningful impact resulting from this change, but as there are no longer tests being
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
features:
- |
Added a new function, :func:`~.transitive_reduction` which returns the transtive reduction
Added a new function, :func:`~.transitive_reduction` which returns the transitive reduction
of a given :class:`~rustworkx.PyDiGraph` and a dictionary with the mapping of indices from the given graph to the returned graph.
The given graph must be a Directed Acyclic Graph (DAG).
For example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ features:
of approximately 40% for iterating through the custom iterables.
These types are not directly nameable or constructable from Python space, and other than the
performance improvement, the behavior should largely not be noticable from Python space.
performance improvement, the behavior should largely not be noticeable from Python space.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fixes:
Fixed the plots of multigraphs using :func:`.mpl_draw`. Previously, parallel edges of
multigraphs were plotted on top of each other, with overlapping arrows and labels.
The radius of parallel edges of the multigraph was fixed to be `0.25` for
`connectionstyle` supporting this argument in :func:`.draw_edges`. The edge lables
`connectionstyle` supporting this argument in :func:`.draw_edges`. The edge labels
were offset to `0.25` in :func:`.draw_edge_labels` to align with their respective
edges. This fix can be tested using the following code:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
features:
- |
Added a new function ``lexicographical_topological_sort`` to the
``rustworkx_core::dag_algo`` module. That is a gneric Rust implementation
``rustworkx_core::dag_algo`` module. That is a generic Rust implementation
for the core rust library that provides the
:func:`.lexicographical_topological_sort` function to Rust users.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ features:
compute the maximum bisimulation or relational coarsest partition of a
graph. This function is based on the algorithm described in the publication
"Three partition refinement algorithms" by Paige and Tarjan. This function
recieves a graph and returns a
receives a graph and returns a
:class:`~rustworkx.RelationalCoarsestPartition`.
- |
Added a new class :class:`~rustworkx.RelationalCoarsestPartition` to output
Expand Down
2 changes: 1 addition & 1 deletion releasenotes/notes/0.15/swap-nox-tox-dea2bb14c400641c.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
other:
- |
For developement of rustworkx the automated testing environment
For development of rustworkx the automated testing environment
tooling used has switched from Tox to instead
`Nox <https://nox.thea.codes/en/stable/>`__. This is has no impact for
end users and is only relevant if you contribute code to rustworkx.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ features:
A new function :func:`rustworkx.networkx_converter` has been added. This
function takes in a networkx ``Graph`` object and will generate an
equivalent :class:`~rustworkx.PyGraph` or :class:`~rustworkx.PyDiGraph`
object. While this function is provided as a convience for users of
object. While this function is provided as a convenience for users of
both rustworkx and networkx, networkx will **not** be added as a dependency
of rustworkx (which precludes a rustworkx->networkx converter, see
:ref:`networkx_converter` for example code on how to build this yourself).
5 changes: 5 additions & 0 deletions releasenotes/notes/fix-typos-8f68ff3d0680b924.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Fix typos detected by `typos <https://github.com/crate-ci/typos>`_.
Add spell checker invocations to the Nox ``lint`` session.
2 changes: 1 addition & 1 deletion rustworkx-core/src/bipartite_coloring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ where
}

// Reconstruct coloring of the original graph by iterating over the edges, finding the
// correponding edge (endpoints) in the multigraph, and selecting the last (not yet
// corresponding edge (endpoints) in the multigraph, and selecting the last (not yet
// assigned) color of that edge
let mut edge_coloring: DictMap<G::EdgeId, usize> = DictMap::with_capacity(graph.edge_count());
for edge in graph.edge_references() {
Expand Down
2 changes: 1 addition & 1 deletion rustworkx-core/src/coloring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ where
/// Arguments:
///
/// * `graph` - The graph object to run the algorithm on
/// * `preset_color_fn` - A callback function that will recieve the node identifier
/// * `preset_color_fn` - A callback function that will receive the node identifier
/// for each node in the graph and is expected to return an `Option<usize>`
/// (wrapped in a `Result`) that is `None` if the node has no preset and
/// the usize represents the preset color.
Expand Down
8 changes: 4 additions & 4 deletions rustworkx-core/src/connectivity/all_simple_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ where

// list of visited nodes
let mut visited: IndexSet<G::NodeId> = IndexSet::from_iter(Some(from));
// list of childs of currently exploring path nodes,
// last elem is list of childs of last visited node
// list of children of currently exploring path nodes,
// last elem is list of children of last visited node
let mut stack = vec![graph.neighbors_directed(from, Outgoing)];

let mut output: DictMap<G::NodeId, Vec<Vec<G::NodeId>>> = DictMap::with_capacity(to.len());
Expand Down Expand Up @@ -174,8 +174,8 @@ where
{
// list of visited nodes
let mut visited: IndexSet<G::NodeId> = IndexSet::from_iter(Some(from));
// list of childs of currently exploring path nodes,
// last elem is list of childs of last visited node
// list of children of currently exploring path nodes,
// last elem is list of children of last visited node
let mut stack = vec![graph.neighbors_directed(from, Outgoing)];

let mut output_path: Option<Vec<G::NodeId>> = None;
Expand Down
2 changes: 1 addition & 1 deletion rustworkx-core/src/connectivity/biconnected.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ mod tests {

#[test]
fn test_biconnected_components1() {
// exmaple from https://web.archive.org/web/20121229123447/http://www.ibluemojo.com/school/articul_algorithm.html
// example from https://web.archive.org/web/20121229123447/http://www.ibluemojo.com/school/articul_algorithm.html
let graph = UnGraph::<(), ()>::from_edges([
(0, 1),
(0, 5),
Expand Down
2 changes: 1 addition & 1 deletion rustworkx-core/src/connectivity/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ where
/// The graph should be undirected. If `source` is specified only the chain
/// decomposition for the connected component containing this node will be returned.
/// This node indicates the root of the depth-first search tree. If it's not
/// specified, a source will be chosen arbitrarly and repeated until all components
/// specified, a source will be chosen arbitrarily and repeated until all components
/// of the graph are searched.
///
/// Returns a list of list of edges where each inner list is a chain.
Expand Down
4 changes: 2 additions & 2 deletions rustworkx-core/src/connectivity/cycle_basis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ where
cycles.push(cycle);
// A cycle was found:
} else if !used.get(&z).unwrap().contains(&neighbor) {
let pn = used.get(&neighbor).unwrap();
let prev_n = used.get(&neighbor).unwrap();
let mut cycle: Vec<G::NodeId> = vec![neighbor, z];
let mut p = pred.get(&z).unwrap();
while !pn.contains(p) {
while !prev_n.contains(p) {
cycle.push(*p);
p = pred.get(p).unwrap();
}
Expand Down
4 changes: 2 additions & 2 deletions rustworkx-core/src/dag_algo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use num_traits::{Num, Zero};
use crate::err::LayersError;

/// Return a pair of [`petgraph::Direction`] values corresponding to the "forwards" and "backwards"
/// direction of graph traversal, based on whether the graph is being traved forwards (following
/// direction of graph traversal, based on whether the graph is being traversed forwards (following
/// the edges) or backward (reversing along edges). The order of returns is (forwards, backwards).
#[inline(always)]
pub fn traversal_directions(reverse: bool) -> (petgraph::Direction, petgraph::Direction) {
Expand Down Expand Up @@ -719,7 +719,7 @@ where
Some(runs)
}

/// Auxiliary struct to make the output of [`collect_runs`] iteratable
/// Auxiliary struct to make the output of [`collect_runs`] iterable
///
/// If the filtering function passed to [`collect_runs`] returns an error, it is propagated
/// through `next` as `Err`. In this case the run in which the error occurred will be skipped
Expand Down
2 changes: 1 addition & 1 deletion rustworkx-core/src/generators/complete_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use super::InvalidInputError;
///
/// * `num_nodes` - The number of nodes to create a complete graph for. Either this or
/// `weights` must be specified. If both this and `weights` are specified, `weights`
/// will take priorty and this argument will be ignored
/// will take priority and this argument will be ignored
/// * `weights` - A `Vec` of node weight objects.
/// * `default_node_weight` - A callable that will return the weight to use
/// for newly created nodes. This is ignored if `weights` is specified.
Expand Down
2 changes: 1 addition & 1 deletion rustworkx-core/src/generators/cycle_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use super::InvalidInputError;
///
/// * `num_nodes` - The number of nodes to create a cycle graph for. Either this or
/// `weights` must be specified. If both this and `weights` are specified, `weights`
/// will take priorty and this argument will be ignored.
/// will take priority and this argument will be ignored.
/// * `weights` - A `Vec` of node weight objects.
/// * `default_node_weight` - A callable that will return the weight to use
/// for newly created nodes. This is ignored if `weights` is specified.
Expand Down
Loading

0 comments on commit 680789b

Please sign in to comment.