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

Bump pyo3 from 0.11.1 to 0.12.3 and numpy from 0.11.0 to 0.12.1 #139

Merged
merged 12 commits into from
Oct 12, 2020
Merged
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