fixed bug introduced by resizing nph
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
//clang-format off
|
||||
typedef struct {
|
||||
PyObject_HEAD FILE *fp;
|
||||
size_t n_left;
|
||||
uint32_t n_left;
|
||||
Py_ssize_t chunk;
|
||||
} ClusterFileReader;
|
||||
//clang-format on
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include "cluster_reader.h"
|
||||
#include <assert.h>
|
||||
|
||||
size_t read_clusters(FILE *fp, size_t n_clusters, Cluster *buf, size_t *n_left) {
|
||||
size_t read_clusters(FILE *fp, size_t n_clusters, Cluster *buf, uint32_t *n_left) {
|
||||
int iframe = 0;
|
||||
size_t nph = *n_left;
|
||||
uint32_t nph = *n_left;
|
||||
|
||||
size_t nph_read = 0;
|
||||
size_t nn = *n_left;
|
||||
uint32_t nn = *n_left;
|
||||
size_t nr = 0;
|
||||
|
||||
// read photons left from previous frame
|
||||
@ -26,8 +26,9 @@ size_t read_clusters(FILE *fp, size_t n_clusters, Cluster *buf, size_t *n_left)
|
||||
// keep on reading frames and photons until reaching n_clusters
|
||||
while (fread(&iframe, sizeof(iframe), 1, fp)) {
|
||||
|
||||
// read number of clusters in frame
|
||||
if (fread(&nph, sizeof(nph), 1, fp)) {
|
||||
if (nph > n_clusters - nph_read)
|
||||
if (nph > (n_clusters - nph_read))
|
||||
nn = n_clusters - nph_read;
|
||||
else
|
||||
nn = nph;
|
||||
@ -45,9 +46,9 @@ size_t read_clusters(FILE *fp, size_t n_clusters, Cluster *buf, size_t *n_left)
|
||||
}
|
||||
|
||||
size_t read_clusters_with_cut(FILE *fp, size_t n_clusters, Cluster *buf,
|
||||
size_t *n_left, double *noise_map, int nx, int ny) {
|
||||
uint32_t *n_left, double *noise_map, int nx, int ny) {
|
||||
int iframe = 0;
|
||||
size_t nph = *n_left;
|
||||
uint32_t nph = *n_left;
|
||||
|
||||
size_t nph_read = 0;
|
||||
|
||||
|
@ -5,9 +5,9 @@
|
||||
#include "data_types.h"
|
||||
//Pure C implementation to read a cluster file
|
||||
|
||||
size_t read_clusters(FILE* fp, size_t n_clusters, Cluster* buf, size_t *n_left);
|
||||
size_t read_clusters(FILE* fp, size_t n_clusters, Cluster* buf, uint32_t *n_left);
|
||||
|
||||
size_t read_clusters_with_cut(FILE* fp, size_t n_clusters, Cluster* buf, size_t *n_left, double *noise_map, int nx, int ny);
|
||||
size_t read_clusters_with_cut(FILE* fp, size_t n_clusters, Cluster* buf, uint32_t *n_left, double *noise_map, int nx, int ny);
|
||||
|
||||
int analyze_clusters(int64_t n_clusters, int32_t* cin, ClusterAnalysis *cout, int csize);
|
||||
|
||||
|
@ -64,7 +64,7 @@ static PyObject *clusterize(PyObject *Py_UNUSED(self), PyObject *args) {
|
||||
|
||||
Py_ssize_t size = 0;
|
||||
PyObject *data_obj;
|
||||
if (!PyArg_ParseTuple(args, "nO", &size,&data_obj)) {
|
||||
if (!PyArg_ParseTuple(args, "nO", &size, &data_obj)) {
|
||||
PyErr_SetString(
|
||||
PyExc_TypeError,
|
||||
"Could not parse args.");
|
||||
|
Reference in New Issue
Block a user