Skip to content

Commit

Permalink
Fix Matplotlib warning when building docs (backport #820) (#822)
Browse files Browse the repository at this point in the history
* Fix Matplotlib warning when building docs (#820)

Fix the warning in the docs because of matplotlib.cm deprecations.

(cherry picked from commit 50c3968)

* Fix clippy with Rust 1.66.0 (#762)

The recent release of Rust 1.66.0 [1] added new on by default clippy rules
which are causing failures when we run the clippy CI job with the new
rust version. This commit updates the code to fix the issues that clippy
has identified which will unblock CI.

[1] https://blog.rust-lang.org/2022/12/15/Rust-1.66.0.html

* Set MSRV for clippy in rustworkx (#793)

Starting in the recently released Rust 1.67.0 clippy enabled a new rule
by default, uninlined_format_args [1], which warns when format!() is
used and a variable is not put in the string inline but isntead as a
separate argument in the macro. For example, `format!("{}", foo)`
Instead the rule suggests using the variable inline the format call
(e.g. `format!("{foo}")`. However, with our msrv of 1.56.1
this syntax was not supported. So trying to fix the places the rule is
triggered as suggested will fail to compile with rust 1.56.1. To address
this and solve this for future rust releases and potential new rules this
commit adds a clippy.toml file which sets the msrv for the rustworkx crate
This will by default disable rules that weren't on by default in rust
1.56.1.

[1] https://rust-lang.github.io/rust-clippy/master/index.html#uninlined_format_args

* Pin tox version used in CI to < 4.0.0 (#761)

The most recent tox release, 4.0.0, is a major rewrite of the internals
of tox and several things behave quite differently. This new release
is causing CI jobs to fail as something in incompatible with our tox
configuration. This commit pins the tox version we're using in CI to
unblock things until we can update the tox configuration to be
compatible with both the new and old versions of tox.

---------

Co-authored-by: Ivan Carvalho <[email protected]>
Co-authored-by: Matthew Treinish <[email protected]>
  • Loading branch information
3 people authored Feb 27, 2023
1 parent 2cebb8d commit 5c6e8ec
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U virtualenv setuptools wheel tox
pip install -U virtualenv setuptools wheel 'tox<4'
sudo apt-get install graphviz pandoc
- name: Build and publish
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U virtualenv setuptools wheel tox
pip install -U virtualenv setuptools wheel 'tox<4'
sudo apt-get install graphviz pandoc
- name: Build and publish
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
profile: minimal
default: true
- name: 'Install dependencies'
run: python -m pip install --upgrade tox
run: python -m pip install --upgrade 'tox<4'
- name: 'Install binary dependencies'
run: sudo apt-get install -y graphviz
if: runner.os == 'Linux'
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
profile: minimal
default: true
- name: 'Install dependencies'
run: python -m pip install --upgrade tox
run: python -m pip install --upgrade 'tox<4'
- name: 'Install binary dependencies'
run: sudo apt-get install -y graphviz
if: runner.os == 'Linux'
Expand Down Expand Up @@ -195,7 +195,7 @@ jobs:
- name: Install binary deps
run: sudo apt-get install -y graphviz
- name: Install deps
run: pip install -U tox
run: pip install -U 'tox<4'
- name: Build Docs
run: tox -edocs
- uses: actions/upload-artifact@v2
Expand Down
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
msrv = "1.56.1"
2 changes: 1 addition & 1 deletion docs/source/tutorial/betweenness_centrality.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Alternatively, you can use :func:`~rustworkx.visualization.graphviz_draw`:
graph[node] = btw

# Leverage matplotlib for color map
colormap = matplotlib.cm.get_cmap("magma")
colormap = matplotlib.colormaps["magma"]
norm = matplotlib.colors.Normalize(
vmin=min(centrality.values()),
vmax=max(centrality.values())
Expand Down
6 changes: 3 additions & 3 deletions src/digraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2688,14 +2688,14 @@ impl PyDiGraph {
}

fn __getitem__(&self, idx: usize) -> PyResult<&PyObject> {
match self.graph.node_weight(NodeIndex::new(idx as usize)) {
match self.graph.node_weight(NodeIndex::new(idx)) {
Some(data) => Ok(data),
None => Err(PyIndexError::new_err("No node found for index")),
}
}

fn __setitem__(&mut self, idx: usize, value: PyObject) -> PyResult<()> {
let data = match self.graph.node_weight_mut(NodeIndex::new(idx as usize)) {
let data = match self.graph.node_weight_mut(NodeIndex::new(idx)) {
Some(node_data) => node_data,
None => return Err(PyIndexError::new_err("No node found for index")),
};
Expand All @@ -2704,7 +2704,7 @@ impl PyDiGraph {
}

fn __delitem__(&mut self, idx: usize) -> PyResult<()> {
match self.graph.remove_node(NodeIndex::new(idx as usize)) {
match self.graph.remove_node(NodeIndex::new(idx)) {
Some(_) => Ok(()),
None => Err(PyIndexError::new_err("No node found for index")),
}
Expand Down
2 changes: 1 addition & 1 deletion src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ impl PyGraph {
}

fn __delitem__(&mut self, idx: usize) -> PyResult<()> {
match self.graph.remove_node(NodeIndex::new(idx as usize)) {
match self.graph.remove_node(NodeIndex::new(idx)) {
Some(_) => Ok(()),
None => Err(PyIndexError::new_err("No node found for index")),
}
Expand Down

0 comments on commit 5c6e8ec

Please sign in to comment.