Skip to content

Commit

Permalink
Bump pyo3 from 0.11.1 to 0.12.3 and numpy from 0.11.0 to 0.12.1 (#139)
Browse files Browse the repository at this point in the history
* Bump pyo3 from 0.11.1 to 0.12.0

Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.11.1 to 0.12.0.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/master/CHANGELOG.md)
- [Commits](PyO3/pyo3@v0.11.1...v0.12.0)

Signed-off-by: dependabot[bot] <[email protected]>

* Update exception usage in new PyO3 version

As documented in the changelog, release notes, and migration guide PyO3
0.12.0 reworked how exceptions are created and used. This was a breaking
change for how retworkx was using exceptions. This commit updates the
usage to be compatible with 0.12.0's new exception API. However, this is
only the first step on updating the PyO3 version and the compilation
still fails, this is currently blocked waiting for a rust-numpy release
that updates its usage to PyO3 0.12.0. Once that is released we can
continue this.

* Bump pyo3 from 0.12.0 to 0.12.1

Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.12.0 to 0.12.1.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/master/CHANGELOG.md)
- [Commits](PyO3/pyo3@v0.12.0...v0.12.1)

* Update new exceptions to PyO3 0.12.0 API

* Bump rust-numpy too

* Bump numpy dep to 0.12.1 to get fix for Rust 1.39.0

* Bump PyO3 to the latest release 0.12.2

* Bump PyO3 to the latest release 0.12.3

Co-authored-by: Matthew Treinish <[email protected]>
  • Loading branch information
dependabot[bot] and mtreinish authored Oct 12, 2020
1 parent 1b0ab32 commit 4d66ef4
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 65 deletions.
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ crate-type = ["cdylib"]
[dependencies]
petgraph = "0.5.1"
fixedbitset = "0.2.0"
numpy = "0.11.0"
numpy = "0.12.1"
ndarray = "0.13.0"
rand = "0.7"
rand_pcg = "0.2"
rayon = "1.4"

[dependencies.pyo3]
version = "0.11.1"
version = "0.12.3"
features = ["extension-module"]

[dependencies.hashbrown]
Expand Down
30 changes: 17 additions & 13 deletions src/digraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::str;
use hashbrown::{HashMap, HashSet};

use pyo3::class::PyMappingProtocol;
use pyo3::exceptions::IndexError;
use pyo3::exceptions::PyIndexError;
use pyo3::prelude::*;
use pyo3::types::{PyDict, PyList, PyLong, PyString, PyTuple};
use pyo3::Python;
Expand Down Expand Up @@ -317,7 +317,7 @@ impl PyDiGraph {
state,
)
{
return Err(DAGWouldCycle::py_err(
return Err(DAGWouldCycle::new_err(
"Adding an edge would cycle",
));
}
Expand Down Expand Up @@ -428,7 +428,7 @@ impl PyDiGraph {
#[setter]
fn set_check_cycle(&mut self, value: bool) -> PyResult<()> {
if !self.check_cycle && value && !is_directed_acyclic_graph(self) {
return Err(DAGHasCycle::py_err("PyDiGraph object has a cycle"));
return Err(DAGHasCycle::new_err("PyDiGraph object has a cycle"));
}
self.check_cycle = value;
Ok(())
Expand Down Expand Up @@ -545,7 +545,7 @@ impl PyDiGraph {
let edge_index = match self.graph.find_edge(index_a, index_b) {
Some(edge_index) => edge_index,
None => {
return Err(NoEdgeBetweenNodes::py_err(
return Err(NoEdgeBetweenNodes::new_err(
"No edge found between nodes",
))
}
Expand All @@ -566,7 +566,9 @@ impl PyDiGraph {
let index = NodeIndex::new(node);
let node = match self.graph.node_weight(index) {
Some(node) => node,
None => return Err(IndexError::py_err("No node found for index")),
None => {
return Err(PyIndexError::new_err("No node found for index"))
}
};
Ok(node)
}
Expand Down Expand Up @@ -595,7 +597,7 @@ impl PyDiGraph {
.map(|edge| edge.weight())
.collect();
if out.is_empty() {
Err(NoEdgeBetweenNodes::py_err("No edge found between nodes"))
Err(NoEdgeBetweenNodes::new_err("No edge found between nodes"))
} else {
Ok(out)
}
Expand Down Expand Up @@ -876,7 +878,7 @@ impl PyDiGraph {
let edge_index = match self.graph.find_edge(p_index, c_index) {
Some(edge_index) => edge_index,
None => {
return Err(NoEdgeBetweenNodes::py_err(
return Err(NoEdgeBetweenNodes::new_err(
"No edge found between nodes",
))
}
Expand Down Expand Up @@ -1026,7 +1028,7 @@ impl PyDiGraph {
match self.graph.find_edge(neighbor, index) {
Some(edge) => edge,
None => {
return Err(NoEdgeBetweenNodes::py_err(
return Err(NoEdgeBetweenNodes::new_err(
"No edge found between nodes",
))
}
Expand All @@ -1035,7 +1037,7 @@ impl PyDiGraph {
match self.graph.find_edge(index, neighbor) {
Some(edge) => edge,
None => {
return Err(NoEdgeBetweenNodes::py_err(
return Err(NoEdgeBetweenNodes::new_err(
"No edge found between nodes",
))
}
Expand Down Expand Up @@ -1189,7 +1191,7 @@ impl PyDiGraph {
return Ok(self.graph.node_weight(edge.target()).unwrap());
}
}
Err(NoSuitableNeighbors::py_err("No suitable neighbor"))
Err(NoSuitableNeighbors::new_err("No suitable neighbor"))
}

/// Generate a dot file from the graph
Expand Down Expand Up @@ -1584,7 +1586,7 @@ impl PyMappingProtocol for PyDiGraph {
fn __getitem__(&'p self, idx: usize) -> PyResult<&'p PyObject> {
match self.graph.node_weight(NodeIndex::new(idx as usize)) {
Some(data) => Ok(data),
None => Err(IndexError::py_err("No node found for index")),
None => Err(PyIndexError::new_err("No node found for index")),
}
}

Expand All @@ -1594,7 +1596,9 @@ impl PyMappingProtocol for PyDiGraph {
.node_weight_mut(NodeIndex::new(idx as usize))
{
Some(node_data) => node_data,
None => return Err(IndexError::py_err("No node found for index")),
None => {
return Err(PyIndexError::new_err("No node found for index"))
}
};
*data = value;
Ok(())
Expand All @@ -1603,7 +1607,7 @@ impl PyMappingProtocol for PyDiGraph {
fn __delitem__(&'p mut self, idx: usize) -> PyResult<()> {
match self.graph.remove_node(NodeIndex::new(idx as usize)) {
Some(_) => Ok(()),
None => Err(IndexError::py_err("No node found for index")),
None => Err(PyIndexError::new_err("No node found for index")),
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/generators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use petgraph::algo;
use petgraph::graph::NodeIndex;
use petgraph::stable_graph::{StableDiGraph, StableUnGraph};

use pyo3::exceptions::IndexError;
use pyo3::exceptions::PyIndexError;
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;
use pyo3::Python;
Expand Down Expand Up @@ -77,7 +77,7 @@ pub fn directed_cycle_graph(
) -> PyResult<digraph::PyDiGraph> {
let mut graph = StableDiGraph::<PyObject, PyObject>::default();
if weights.is_none() && num_nodes.is_none() {
return Err(IndexError::py_err(
return Err(PyIndexError::new_err(
"num_nodes and weights list not specified",
));
}
Expand Down Expand Up @@ -161,7 +161,7 @@ pub fn cycle_graph(
) -> PyResult<graph::PyGraph> {
let mut graph = StableUnGraph::<PyObject, PyObject>::default();
if weights.is_none() && num_nodes.is_none() {
return Err(IndexError::py_err(
return Err(PyIndexError::new_err(
"num_nodes and weights list not specified",
));
}
Expand Down Expand Up @@ -243,7 +243,7 @@ pub fn directed_path_graph(
) -> PyResult<digraph::PyDiGraph> {
let mut graph = StableDiGraph::<PyObject, PyObject>::default();
if weights.is_none() && num_nodes.is_none() {
return Err(IndexError::py_err(
return Err(PyIndexError::new_err(
"num_nodes and weights list not specified",
));
}
Expand Down Expand Up @@ -319,7 +319,7 @@ pub fn path_graph(
) -> PyResult<graph::PyGraph> {
let mut graph = StableUnGraph::<PyObject, PyObject>::default();
if weights.is_none() && num_nodes.is_none() {
return Err(IndexError::py_err(
return Err(PyIndexError::new_err(
"num_nodes and weights list not specified",
));
}
Expand Down Expand Up @@ -419,7 +419,7 @@ pub fn directed_star_graph(
) -> PyResult<digraph::PyDiGraph> {
let mut graph = StableDiGraph::<PyObject, PyObject>::default();
if weights.is_none() && num_nodes.is_none() {
return Err(IndexError::py_err(
return Err(PyIndexError::new_err(
"num_nodes and weights list not specified",
));
}
Expand Down Expand Up @@ -496,7 +496,7 @@ pub fn star_graph(
) -> PyResult<graph::PyGraph> {
let mut graph = StableUnGraph::<PyObject, PyObject>::default();
if weights.is_none() && num_nodes.is_none() {
return Err(IndexError::py_err(
return Err(PyIndexError::new_err(
"num_nodes and weights list not specified",
));
}
Expand Down
20 changes: 12 additions & 8 deletions src/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::str;
use hashbrown::HashMap;

use pyo3::class::PyMappingProtocol;
use pyo3::exceptions::IndexError;
use pyo3::exceptions::PyIndexError;
use pyo3::prelude::*;
use pyo3::types::{PyDict, PyList, PyLong, PyString, PyTuple};
use pyo3::Python;
Expand Down Expand Up @@ -398,7 +398,7 @@ impl PyGraph {
let edge_index = match self.graph.find_edge(index_a, index_b) {
Some(edge_index) => edge_index,
None => {
return Err(NoEdgeBetweenNodes::py_err(
return Err(NoEdgeBetweenNodes::new_err(
"No edge found between nodes",
))
}
Expand All @@ -419,7 +419,9 @@ impl PyGraph {
let index = NodeIndex::new(node);
let node = match self.graph.node_weight(index) {
Some(node) => node,
None => return Err(IndexError::py_err("No node found for index")),
None => {
return Err(PyIndexError::new_err("No node found for index"))
}
};
Ok(node)
}
Expand Down Expand Up @@ -447,7 +449,7 @@ impl PyGraph {
.map(|edge| edge.weight())
.collect();
if out.is_empty() {
Err(NoEdgeBetweenNodes::py_err("No edge found between nodes"))
Err(NoEdgeBetweenNodes::new_err("No edge found between nodes"))
} else {
Ok(out)
}
Expand Down Expand Up @@ -652,7 +654,7 @@ impl PyGraph {
let edge_index = match self.graph.find_edge(p_index, c_index) {
Some(edge_index) => edge_index,
None => {
return Err(NoEdgeBetweenNodes::py_err(
return Err(NoEdgeBetweenNodes::new_err(
"No edge found between nodes",
))
}
Expand Down Expand Up @@ -1129,7 +1131,7 @@ impl PyMappingProtocol for PyGraph {
fn __getitem__(&'p self, idx: usize) -> PyResult<&'p PyObject> {
match self.graph.node_weight(NodeIndex::new(idx as usize)) {
Some(data) => Ok(data),
None => Err(IndexError::py_err("No node found for index")),
None => Err(PyIndexError::new_err("No node found for index")),
}
}

Expand All @@ -1139,7 +1141,9 @@ impl PyMappingProtocol for PyGraph {
.node_weight_mut(NodeIndex::new(idx as usize))
{
Some(node_data) => node_data,
None => return Err(IndexError::py_err("No node found for index")),
None => {
return Err(PyIndexError::new_err("No node found for index"))
}
};
*data = value;
Ok(())
Expand All @@ -1148,7 +1152,7 @@ impl PyMappingProtocol for PyGraph {
fn __delitem__(&'p mut self, idx: usize) -> PyResult<()> {
match self.graph.remove_node(NodeIndex::new(idx as usize)) {
Some(_) => Ok(()),
None => Err(IndexError::py_err("No node found for index")),
None => Err(PyIndexError::new_err("No node found for index")),
}
}
}
Loading

0 comments on commit 4d66ef4

Please sign in to comment.