Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0cdec6c

Browse files
committed
Bugfix to ensure Bbox.update_numerix() handles nan as first element of
sequence OK. -- ADS svn path=/trunk/matplotlib/; revision=1918
1 parent d1f66d6 commit 0cdec6c

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

src/_transforms.cpp

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -482,18 +482,37 @@ Bbox::update_numerix(const Py::Tuple &args) {
482482
double thisx, thisy;
483483
int ignore = Py::Int(args[2]);
484484
if (ignore) {
485-
thisx = *(double *)(x->data);
486-
thisy = *(double *)(y->data);
487-
minx=thisx;
488-
maxx=thisx;
489-
miny=thisy;
490-
maxy=thisy;
485+
int xok=0;
486+
int yok=0;
487+
// loop through values until we find some nans...
488+
for (size_t i=0; i< Nx; ++i) {
489+
thisx = *(double *)(x->data + i*x->strides[0]);
490+
thisy = *(double *)(y->data + i*y->strides[0]);
491+
492+
if (!xok) {
493+
if (!isnan(thisx)) {
494+
minx=thisx;
495+
maxx=thisx;
496+
xok=1;
497+
}
498+
}
499+
500+
if (!yok) {
501+
if (!isnan(thisy)) {
502+
miny=thisy;
503+
maxy=thisx;
504+
yok=1;
505+
}
506+
}
507+
508+
if (xok && yok) break;
509+
}
491510
}
492511

493512
for (size_t i=0; i< Nx; ++i) {
494-
495513
thisx = *(double *)(x->data + i*x->strides[0]);
496514
thisy = *(double *)(y->data + i*y->strides[0]);
515+
497516
_posx.update(thisx);
498517
_posy.update(thisy);
499518
if (thisx<minx) minx=thisx;

0 commit comments

Comments
 (0)