Skip to content

Commit 6ea9ed0

Browse files
committed
fix: all test cases pass on my machine, yay
1 parent f97e0ac commit 6ea9ed0

File tree

5 files changed

+31
-16
lines changed

5 files changed

+31
-16
lines changed

src/_igraph/attributes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ static int igraphmodule_i_attribute_copy(igraph_t *to, const igraph_t *from,
413413
}
414414

415415
/* Adding vertices */
416-
static int igraphmodule_i_attribute_add_vertices(igraph_t *graph, long int nv, igraph_vector_ptr_t *attr) {
416+
static int igraphmodule_i_attribute_add_vertices(igraph_t *graph, igraph_integer_t nv, igraph_vector_ptr_t *attr) {
417417
/* Extend the end of every value in the vertex hash with nv pieces of None */
418418
PyObject *key, *value, *dict;
419419
long int i, j, k, l;

src/_igraph/convert.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,7 @@ PyObject* igraphmodule_vector_int_t_to_PyList(const igraph_vector_int_t *v) {
13371337

13381338
list=PyList_New(n);
13391339
for (i=0; i<n; i++) {
1340+
/* TODO: what if igraph_integer_t is larger than a long? */
13401341
item = PyLong_FromLong((long)VECTOR(*v)[i]);
13411342
if (!item) {
13421343
Py_DECREF(list);

src/_igraph/edgeseqobject.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ PyTypeObject igraphmodule_EdgeSeqType;
4646
* \return the allocated PyObject
4747
*/
4848
PyObject* igraphmodule_EdgeSeq_new(PyTypeObject *subtype,
49-
PyObject *args, PyObject *kwds) {
49+
PyObject *args, PyObject *kwds) {
5050
igraphmodule_EdgeSeqObject* o;
5151

5252
o=(igraphmodule_EdgeSeqObject*)PyType_GenericNew(subtype, args, kwds);
@@ -124,7 +124,7 @@ int igraphmodule_EdgeSeq_init(igraphmodule_EdgeSeqObject *self,
124124
}
125125
igraph_es_1(&es, (igraph_integer_t)idx);
126126
} else {
127-
/* We selected multiple edges */
127+
/* We selected multiple edges */
128128
igraph_vector_int_t v;
129129
igraph_integer_t n = igraph_ecount(&((igraphmodule_GraphObject*)g)->g);
130130
if (igraphmodule_PyObject_to_vector_int_t(esobj, &v))
@@ -228,9 +228,17 @@ PyObject* igraphmodule_EdgeSeq_sq_item(igraphmodule_EdgeSeqObject* self,
228228
}
229229
break;
230230

231+
case IGRAPH_ES_NONE:
232+
break;
233+
231234
/* TODO: IGRAPH_ES_PAIRS, IGRAPH_ES_ADJ, IGRAPH_ES_PATH,
232235
IGRAPH_ES_MULTIPATH - someday :) They are unused yet in the Python
233236
interface */
237+
238+
default:
239+
return PyErr_Format(
240+
igraphmodule_InternalError, "unsupported edge selector type: %d", igraph_es_type(&self->es)
241+
);
234242
}
235243
if (idx < 0) {
236244
PyErr_SetString(PyExc_IndexError, "edge index out of range");

src/_igraph/graphobject.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6352,32 +6352,32 @@ typedef struct {
63526352
PyObject* graph;
63536353
} igraphmodule_i_Graph_motifs_randesu_callback_data_t;
63546354

6355-
igraph_bool_t igraphmodule_i_Graph_motifs_randesu_callback(const igraph_t *graph,
6356-
igraph_vector_t *vids, int isoclass, void* extra) {
6355+
igraph_error_t igraphmodule_i_Graph_motifs_randesu_callback(const igraph_t *graph,
6356+
igraph_vector_int_t *vids, int isoclass, void* extra) {
63576357
igraphmodule_i_Graph_motifs_randesu_callback_data_t* data =
63586358
(igraphmodule_i_Graph_motifs_randesu_callback_data_t*)extra;
63596359
PyObject* vector;
63606360
PyObject* result;
63616361
igraph_bool_t retval;
63626362

6363-
vector = igraphmodule_vector_t_to_PyList(vids, IGRAPHMODULE_TYPE_INT);
6363+
vector = igraphmodule_vector_int_t_to_PyList(vids);
63646364
if (vector == NULL) {
63656365
/* Error in conversion, return 1 */
6366-
return 1;
6366+
return IGRAPH_FAILURE;
63676367
}
63686368

63696369
result = PyObject_CallFunction(data->func, "OOi", data->graph, vector, isoclass);
63706370
Py_DECREF(vector);
63716371

63726372
if (result == NULL) {
63736373
/* Error in callback, return 1 */
6374-
return 1;
6374+
return IGRAPH_FAILURE;
63756375
}
63766376

63776377
retval = PyObject_IsTrue(result);
63786378
Py_DECREF(result);
63796379

6380-
return retval;
6380+
return retval ? IGRAPH_STOP : IGRAPH_SUCCESS;
63816381
}
63826382

63836383
/** \ingroup python_interface_graph
@@ -8819,17 +8819,17 @@ igraph_bool_t igraphmodule_i_Graph_isomorphic_vf2_callback_fn(
88198819

88208820
map12_o = igraphmodule_vector_int_t_to_PyList(map12);
88218821
if (map12_o == NULL) {
8822-
/* Error in conversion, return 0 to stop the search */
8822+
/* Error in conversion, return an error code */
88238823
PyErr_WriteUnraisable(data->callback_fn);
8824-
return 0;
8824+
return IGRAPH_FAILURE;
88258825
}
88268826

88278827
map21_o = igraphmodule_vector_int_t_to_PyList(map21);
88288828
if (map21_o == NULL) {
8829-
/* Error in conversion, return 0 to stop the search */
8829+
/* Error in conversion, return an error code */
88308830
PyErr_WriteUnraisable(data->callback_fn);
88318831
Py_DECREF(map21_o);
8832-
return 0;
8832+
return IGRAPH_FAILURE;
88338833
}
88348834

88358835
result = PyObject_CallFunction(data->callback_fn, "OOOO", data->graph1, data->graph2,
@@ -8838,15 +8838,15 @@ igraph_bool_t igraphmodule_i_Graph_isomorphic_vf2_callback_fn(
88388838
Py_DECREF(map21_o);
88398839

88408840
if (result == NULL) {
8841-
/* Error in callback, return 0 */
8841+
/* Error in callback, return an error code */
88428842
PyErr_WriteUnraisable(data->callback_fn);
8843-
return 0;
8843+
return IGRAPH_FAILURE;
88448844
}
88458845

88468846
retval = PyObject_IsTrue(result);
88478847
Py_DECREF(result);
88488848

8849-
return retval;
8849+
return retval ? IGRAPH_SUCCESS : IGRAPH_STOP;
88508850
}
88518851

88528852
igraph_bool_t igraphmodule_i_Graph_isomorphic_vf2_node_compat_fn(

src/_igraph/vertexseqobject.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ PyObject* igraphmodule_VertexSeq_sq_item(igraphmodule_VertexSeqObject* self,
213213
idx = self->vs.data.vid;
214214
}
215215
break;
216+
case IGRAPH_VS_NONE:
217+
break;
216218
case IGRAPH_VS_SEQ:
217219
if (i < 0) {
218220
i = self->vs.data.seq.to - self->vs.data.seq.from + i;
@@ -223,6 +225,10 @@ PyObject* igraphmodule_VertexSeq_sq_item(igraphmodule_VertexSeqObject* self,
223225
break;
224226
/* TODO: IGRAPH_VS_ADJ, IGRAPH_VS_NONADJ - someday :) They are unused
225227
yet in the Python interface */
228+
default:
229+
return PyErr_Format(
230+
igraphmodule_InternalError, "unsupported vertex selector type: %d", igraph_vs_type(&self->vs)
231+
);
226232
}
227233

228234
if (idx < 0) {

0 commit comments

Comments
 (0)