|
6 | 6 | #include "mplutils.h" |
7 | 7 | #include "MPL_isnan.h" |
8 | 8 |
|
9 | | - |
10 | 9 | #include "numpy/arrayobject.h" |
11 | | -//#include "numpy/ufuncobject.h" |
12 | | - |
13 | | - |
14 | | -//bool skip_float(double x) { |
15 | | -// return !MPL_isnan64(x) && !isinf(x); |
16 | | -//} |
17 | 10 |
|
18 | 11 | Value::~Value() { |
19 | 12 | _VERBOSE("Value::~Value"); |
@@ -470,28 +463,22 @@ Bbox::update(const Py::Tuple &args) { |
470 | 463 |
|
471 | 464 | Py::Tuple tup; |
472 | 465 | if (ignore) { |
473 | | - tup = xys[0]; |
474 | | - double x = Py::Float(tup[0]); |
475 | | - double y = Py::Float(tup[1]); |
476 | | - |
477 | | - minx=x; |
478 | | - maxx=x; |
479 | | - miny=y; |
480 | | - maxy=y; |
| 466 | + minx = miny = std::numeric_limits<double>::max(); |
| 467 | + maxx = maxy = std::numeric_limits<double>::min(); |
481 | 468 | } |
482 | 469 |
|
483 | 470 |
|
484 | 471 | for (size_t i=0; i<Nx; ++i) { |
485 | 472 | tup = xys[i]; |
486 | 473 | double x = Py::Float(tup[0]); |
487 | 474 | double y = Py::Float(tup[1]); |
| 475 | + if (MPL_isnan64(x) || MPL_isnan64(y)) continue; |
488 | 476 | _posx.update(x); |
489 | 477 | _posy.update(y); |
490 | 478 | if (x<minx) minx=x; |
491 | 479 | if (x>maxx) maxx=x; |
492 | 480 | if (y<miny) miny=y; |
493 | 481 | if (y>maxy) maxy=y; |
494 | | - |
495 | 482 | } |
496 | 483 |
|
497 | 484 |
|
@@ -617,37 +604,14 @@ Bbox::update_numerix(const Py::Tuple &args) { |
617 | 604 | _ignore = 0; // don't ignore future updates |
618 | 605 | } |
619 | 606 | if (ignore) { |
620 | | - int xok=0; |
621 | | - int yok=0; |
622 | | - // loop through values until we find some nans... |
623 | | - for (size_t i=0; i< Nx; ++i) { |
624 | | - thisx = *(double *)(x->data + i*x->strides[0]); |
625 | | - thisy = *(double *)(y->data + i*y->strides[0]); |
626 | | - |
627 | | - if (!xok) { |
628 | | - if (!MPL_isnan64(thisx)) { |
629 | | - minx=thisx; |
630 | | - maxx=thisx; |
631 | | - xok=1; |
632 | | - } |
633 | | - } |
634 | | - |
635 | | - if (!yok) { |
636 | | - if (!MPL_isnan64(thisy)) { |
637 | | - miny=thisy; |
638 | | - maxy=thisy; |
639 | | - yok=1; |
640 | | - } |
641 | | - } |
642 | | - |
643 | | - if (xok && yok) break; |
644 | | - } |
| 607 | + minx = miny = std::numeric_limits<double>::max(); |
| 608 | + maxx = maxy = -std::numeric_limits<double>::max(); |
645 | 609 | } |
646 | 610 |
|
647 | 611 | for (size_t i=0; i< Nx; ++i) { |
648 | 612 | thisx = *(double *)(x->data + i*x->strides[0]); |
649 | 613 | thisy = *(double *)(y->data + i*y->strides[0]); |
650 | | - |
| 614 | + if (MPL_isnan64(thisx) || MPL_isnan64(thisy)) continue; |
651 | 615 | _posx.update(thisx); |
652 | 616 | _posy.update(thisy); |
653 | 617 | if (thisx<minx) minx=thisx; |
|
0 commit comments