Skip to content

Commit bc27f42

Browse files
committed
We want (most) arrays to be initialized with zeros! Bug?
1 parent 33a3e2c commit bc27f42

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

pysais.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static PyObject *python_sais(PyObject *self, PyObject *args)
4949
int n = strlen((const char *)T);
5050
npy_intp dims[2];
5151
dims[0] = n;
52-
SA_np = (PyArrayObject *) PyArray_SimpleNew(1, dims, NPY_INT);
52+
SA_np = (PyArrayObject *) PyArray_ZEROS(1, dims, NPY_INT, 0);
5353
SA = pyvector_to_Carrayptrs(SA_np);
5454
int res = sais(T, SA, n);
5555
if (res < 0)
@@ -89,7 +89,7 @@ static PyObject *python_sais_int(PyObject *self, PyObject *args)
8989
}
9090
npy_intp dims[2];
9191
dims[0] = n;
92-
SA_np = (PyArrayObject *) PyArray_SimpleNew(1, dims, NPY_INT);
92+
SA_np = (PyArrayObject *) PyArray_ZEROS(1, dims, NPY_INT, 0);
9393
SA = pyvector_to_Carrayptrs(SA_np);
9494
int res = sais_int(T, SA, n, k);
9595
if (res < 0)
@@ -231,12 +231,12 @@ static PyObject *python_lcp(PyObject *self, PyObject *args)
231231
}
232232
npy_intp dims[2];
233233
dims[0] = n;
234-
LCP_np = (PyArrayObject *) PyArray_SimpleNew(1, dims, NPY_INT);
234+
LCP_np = (PyArrayObject *) PyArray_ZEROS(1, dims, NPY_INT, 0);
235235
LCP = pyvector_to_Carrayptrs(LCP_np);
236236
dims[0]--;
237-
LCP_left_np = (PyArrayObject *) PyArray_SimpleNew(1, dims, NPY_INT);
237+
LCP_left_np = (PyArrayObject *) PyArray_ZEROS(1, dims, NPY_INT, 0);
238238
LCP_left = pyvector_to_Carrayptrs(LCP_left_np);
239-
LCP_right_np = (PyArrayObject *) PyArray_SimpleNew(1, dims, NPY_INT);
239+
LCP_right_np = (PyArrayObject *) PyArray_ZEROS(1, dims, NPY_INT, 0);
240240
LCP_right = pyvector_to_Carrayptrs(LCP_right_np);
241241
int *rank = malloc(n * sizeof(int));
242242
if (rank == NULL)
@@ -424,7 +424,7 @@ PyObject *python_count_occurrences(PyObject *self, PyObject *args)
424424
PyArrayObject *counts_np;
425425
char *counts;
426426
int k;
427-
counts_np = (PyArrayObject *) PyArray_SimpleNew(1, dims, NPY_BYTE);
427+
counts_np = (PyArrayObject *) PyArray_ZEROS(1, dims, NPY_BYTE, 0);
428428
if (found)
429429
{
430430
counts = (char *)counts_np->data;
@@ -491,7 +491,7 @@ PyObject *python_count_position_occurrences(PyObject *self, PyObject *args)
491491
PyArrayObject *counts_np;
492492
char *counts;
493493
int j, k;
494-
counts_np = (PyArrayObject *) PyArray_SimpleNew(2, dims, NPY_BYTE);
494+
counts_np = (PyArrayObject *) PyArray_ZEROS(2, dims, NPY_BYTE, 0);
495495
if (found)
496496
{
497497
counts = (char *)counts_np->data;

0 commit comments

Comments
 (0)