Skip to content

Commit c9e1849

Browse files
committed
🖊️ review code
1 parent 21b1b01 commit c9e1849

File tree

1 file changed

+4
-2
lines changed
  • plotly_resampler/aggregation/algorithms

1 file changed

+4
-2
lines changed

plotly_resampler/aggregation/algorithms/lttbcv2.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <numpy/npy_math.h>
66
#include <math.h>
77

8+
// This code is adapted from https://github.com/dgoeries/lttbc
9+
// Most credits are due to https://github.com/dgoeries
810

911
// method below assumes the x-delta's are equidistant
1012
static PyObject* downsample_return_index(PyObject *self, PyObject *args) {
@@ -15,7 +17,7 @@ static PyObject* downsample_return_index(PyObject *self, PyObject *args) {
1517
if (!PyArg_ParseTuple(args, "OOi", &x_obj, &y_obj, &threshold))
1618
return NULL;
1719

18-
if ((!PyArray_Check(x_obj) && !PyList_Check(y_obj))) {
20+
if ((!PyArray_Check(x_obj) && !PyList_Check(x_obj)) || (!PyArray_Check(y_obj) && !PyList_Check(y_obj))) {
1921
PyErr_SetString(PyExc_TypeError, "Function requires x and y input to be of type list or ndarray ...");
2022
goto fail;
2123
}
@@ -29,7 +31,7 @@ static PyObject* downsample_return_index(PyObject *self, PyObject *args) {
2931
}
3032

3133
if (PyArray_NDIM(x_array) != 1 || PyArray_NDIM(y_array) != 1) {;
32-
PyErr_SetString(PyExc_ValueError, "Y must have a single dimension ...");
34+
PyErr_SetString(PyExc_ValueError, "Both x and y must have a single dimension ...");
3335
goto fail;
3436
}
3537

0 commit comments

Comments
 (0)