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

Skip to content

Commit 7362369

Browse files
committed
some minor cleanups in transform limits stuff
svn path=/trunk/matplotlib/; revision=3516
1 parent 2800827 commit 7362369

2 files changed

Lines changed: 8 additions & 42 deletions

File tree

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2007-07-13 Some minor cleanups in _transforms.cpp - ADS
2+
13
2007-07-13 Removed the rest of the numerix extension code detritus,
24
numpified axes.py, and cleaned up the imports in axes.py
35
- JDH

src/_transforms.cpp

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,7 @@
66
#include "mplutils.h"
77
#include "MPL_isnan.h"
88

9-
109
#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-
//}
1710

1811
Value::~Value() {
1912
_VERBOSE("Value::~Value");
@@ -470,28 +463,22 @@ Bbox::update(const Py::Tuple &args) {
470463

471464
Py::Tuple tup;
472465
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();
481468
}
482469

483470

484471
for (size_t i=0; i<Nx; ++i) {
485472
tup = xys[i];
486473
double x = Py::Float(tup[0]);
487474
double y = Py::Float(tup[1]);
475+
if (MPL_isnan64(x) || MPL_isnan64(y)) continue;
488476
_posx.update(x);
489477
_posy.update(y);
490478
if (x<minx) minx=x;
491479
if (x>maxx) maxx=x;
492480
if (y<miny) miny=y;
493481
if (y>maxy) maxy=y;
494-
495482
}
496483

497484

@@ -617,37 +604,14 @@ Bbox::update_numerix(const Py::Tuple &args) {
617604
_ignore = 0; // don't ignore future updates
618605
}
619606
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();
645609
}
646610

647611
for (size_t i=0; i< Nx; ++i) {
648612
thisx = *(double *)(x->data + i*x->strides[0]);
649613
thisy = *(double *)(y->data + i*y->strides[0]);
650-
614+
if (MPL_isnan64(thisx) || MPL_isnan64(thisy)) continue;
651615
_posx.update(thisx);
652616
_posy.update(thisy);
653617
if (thisx<minx) minx=thisx;

0 commit comments

Comments
 (0)