static PyObject * isnan64(PyObject *self, PyObject *args) { double input; if (!PyArg_ParseTuple(args, "d", &input)) return NULL; if (MPL_isnan64(input)) { Py_INCREF(Py_True); return Py_True; } Py_INCREF(Py_False); return Py_False; }
Py::Object Bbox::update_numerix(const Py::Tuple &args) { //update the box from the numerix arrays x and y _VERBOSE("Bbox::update_numerix"); args.verify_length(3); Py::Object xo = args[0]; Py::Object yo = args[1]; PyArrayObject *x = (PyArrayObject *) PyArray_ContiguousFromObject(xo.ptr(), PyArray_DOUBLE, 1, 1); if (x==NULL) throw Py::TypeError("Bbox::update_numerix expected numerix array"); PyArrayObject *y = (PyArrayObject *) PyArray_ContiguousFromObject(yo.ptr(), PyArray_DOUBLE, 1, 1); if (y==NULL) throw Py::TypeError("Bbox::update_numerix expected numerix array"); size_t Nx = x->dimensions[0]; size_t Ny = y->dimensions[0]; if (Nx!=Ny) throw Py::ValueError("x and y must be equal length sequences"); //don't use current bounds when updating box if ignore==1 if (Nx==0) return Py::Object(); double minx = _ll->xval(); double maxx = _ur->xval(); double miny = _ll->yval(); double maxy = _ur->yval(); double thisx, thisy; int ignore = Py::Int(args[2]); if (ignore) { int xok=0; int yok=0; // loop through values until we find some nans... for (size_t i=0; i< Nx; ++i) { thisx = *(double *)(x->data + i*x->strides[0]); thisy = *(double *)(y->data + i*y->strides[0]); if (!xok) { if (!MPL_isnan64(thisx)) { minx=thisx; maxx=thisx; xok=1; } } if (!yok) { if (!MPL_isnan64(thisy)) { miny=thisy; maxy=thisy; yok=1; } } if (xok && yok) break; } } for (size_t i=0; i< Nx; ++i) { thisx = *(double *)(x->data + i*x->strides[0]); thisy = *(double *)(y->data + i*y->strides[0]); _posx.update(thisx); _posy.update(thisy); if (thisx<minx) minx=thisx; if (thisx>maxx) maxx=thisx; if (thisy<miny) miny=thisy; if (thisy>maxy) maxy=thisy; } Py_XDECREF(x); Py_XDECREF(y); _ll->x_api()->set_api(minx); _ll->y_api()->set_api(miny); _ur->x_api()->set_api(maxx); _ur->y_api()->set_api(maxy); return Py::Object(); }