Skip to content

Commit

Permalink
Using Python Number protocol for weights. Solves #39.
Browse files Browse the repository at this point in the history
  • Loading branch information
vtraag committed Aug 28, 2018
1 parent ec1c6e1 commit ef30084
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/python_partition_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,9 @@ Graph* create_graph_from_py(PyObject* py_obj_graph, PyObject* py_weights, PyObje
const char* s = PyUnicode_AsUTF8(py_item_repr);
cerr << "Got item " << e << ": " << s << endl;
#endif
#ifdef IS_PY3K
if (PyFloat_Check(py_item) || PyLong_Check(py_item))
#else
if (PyFloat_Check(py_item) || PyInt_Check(py_item) || PyLong_Check(py_item))
#endif
if (PyNumber_Check(py_item))
{
weights[e] = PyFloat_AsDouble(py_item);
weights[e] = PyFloat_AsDouble(PyNumber_Float(py_item));
}
else
{
Expand Down

0 comments on commit ef30084

Please sign in to comment.