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

Skip to content

Commit 7861461

Browse files
committed
Removed our own MPL_isnan.h in favor of numpy's implementation
svn path=/trunk/matplotlib/; revision=3512
1 parent b963c4a commit 7861461

7 files changed

Lines changed: 24 additions & 130 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2007-07-13 Removed our own MPL_isnan.h in favor of numpy's
2+
implementation -ADS
3+
14
2007-07-13 Added legend.loc as configurable option that could in
25
future default to 'best'. - NN
36

setup.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
from setupext import build_agg, build_gtkagg, build_tkagg, build_wxagg,\
8383
build_ft2font, build_image, build_windowing, build_transforms, \
8484
build_contour, build_nxutils, build_enthought, build_swigagg, build_gdk, \
85-
build_subprocess, build_isnan, build_ttconv
85+
build_subprocess, build_ttconv
8686
import distutils.sysconfig
8787

8888
for line in file('lib/matplotlib/__init__.py').readlines():
@@ -156,8 +156,6 @@
156156
if sys.platform == 'win32':
157157
build_subprocess(ext_modules, packages)
158158

159-
build_isnan(ext_modules, packages)
160-
161159
try: import datetime
162160
except ImportError: havedate = False
163161
else: havedate = True

setupext.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -943,11 +943,3 @@ def build_subprocess(ext_modules, packages):
943943
)
944944
add_base_flags(module)
945945
ext_modules.append(module)
946-
947-
def build_isnan(ext_modules, packages):
948-
module = Extension(
949-
'matplotlib._isnan',
950-
[ 'src/_isnan.c'],
951-
)
952-
add_base_flags(module)
953-
ext_modules.append(module)

src/MPL_isnan.h

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/_backend_agg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "_backend_agg.h"
2424
#include "_transforms.h"
2525
#include "mplutils.h"
26-
#include "MPL_isnan.h"
2726

2827
#include "swig_runtime.h"
2928

@@ -35,6 +34,7 @@
3534
#else
3635
#define PY_ARRAY_TYPES_PREFIX NumPy
3736
#include "numpy/arrayobject.h"
37+
#include "numpy/ufuncobject.h"
3838
#endif
3939
#endif
4040

@@ -1592,7 +1592,7 @@ RendererAgg::draw_lines(const Py::Tuple& args) {
15921592
moveto = true;
15931593
continue;
15941594
}
1595-
if (MPL_isnan64(thisx) || MPL_isnan64(thisy)) {
1595+
if (isnan(thisx) || isnan(thisy)) {
15961596
moveto = true;
15971597
continue;
15981598
}

src/_isnan.c

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/_transforms.cpp

Lines changed: 18 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44

55
#include "_transforms.h"
66
#include "mplutils.h"
7-
#include "MPL_isnan.h"
87

98

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-
//}
10+
#include "numpy/ufuncobject.h"
11+
#if !defined(isfinite)
12+
#define isfinite(x) (!(isinf((x)) || isnan((x))))
13+
#endif
1714

1815
Value::~Value() {
1916
_VERBOSE("Value::~Value");
@@ -471,31 +468,23 @@ Bbox::update(const Py::Tuple &args) {
471468

472469
Py::Tuple tup;
473470
if (ignore) {
474-
tup = xys[0];
475-
double x = Py::Float(tup[0]);
476-
double y = Py::Float(tup[1]);
477-
478-
minx=x;
479-
maxx=x;
480-
miny=y;
481-
maxy=y;
471+
minx = miny = std::numeric_limits<double>::max();
472+
maxx = maxy = std::numeric_limits<double>::min();
482473
}
483474

484-
485475
for (size_t i=0; i<Nx; ++i) {
486476
tup = xys[i];
487477
double x = Py::Float(tup[0]);
488478
double y = Py::Float(tup[1]);
479+
if (isnan(x) || isnan(y)) continue;
489480
_posx.update(x);
490481
_posy.update(y);
491482
if (x<minx) minx=x;
492483
if (x>maxx) maxx=x;
493484
if (y<miny) miny=y;
494485
if (y>maxy) maxy=y;
495-
496486
}
497487

498-
499488
_ll->x_api()->set_api(minx);
500489
_ll->y_api()->set_api(miny);
501490
_ur->x_api()->set_api(maxx);
@@ -551,7 +540,7 @@ Bbox::update_numerix_xy(const Py::Tuple &args) {
551540
for (size_t i=0; i< Nxy; ++i) {
552541
thisx = *(double *)(xyin->data + i*xyin->strides[0]);
553542
thisy = *(double *)(xyin->data + i*xyin->strides[0] + xyin->strides[1]);
554-
if (MPL_isnan64(thisx) || MPL_isnan64(thisy)) continue;
543+
if (isnan(thisx) || isnan(thisy)) continue;
555544
_posx.update(thisx);
556545
_posy.update(thisy);
557546
if (thisx<minx) minx=thisx;
@@ -618,37 +607,14 @@ Bbox::update_numerix(const Py::Tuple &args) {
618607
_ignore = 0; // don't ignore future updates
619608
}
620609
if (ignore) {
621-
int xok=0;
622-
int yok=0;
623-
// loop through values until we find some nans...
624-
for (size_t i=0; i< Nx; ++i) {
625-
thisx = *(double *)(x->data + i*x->strides[0]);
626-
thisy = *(double *)(y->data + i*y->strides[0]);
627-
628-
if (!xok) {
629-
if (!MPL_isnan64(thisx)) {
630-
minx=thisx;
631-
maxx=thisx;
632-
xok=1;
633-
}
634-
}
635-
636-
if (!yok) {
637-
if (!MPL_isnan64(thisy)) {
638-
miny=thisy;
639-
maxy=thisy;
640-
yok=1;
641-
}
642-
}
643-
644-
if (xok && yok) break;
645-
}
610+
minx = miny = std::numeric_limits<double>::max();
611+
maxx = maxy = std::numeric_limits<double>::min();
646612
}
647613

648614
for (size_t i=0; i< Nx; ++i) {
649615
thisx = *(double *)(x->data + i*x->strides[0]);
650616
thisy = *(double *)(y->data + i*y->strides[0]);
651-
617+
if (isnan(thisx) || isnan(thisy)) continue;
652618
_posx.update(thisx);
653619
_posy.update(thisy);
654620
if (thisx<minx) minx=thisx;
@@ -1290,18 +1256,18 @@ Transformation::nonlinear_only_numerix(const Py::Tuple & args, const Py::Dict &k
12901256

12911257
double thisx = *(double *)(x->data + i*x->strides[0]);
12921258
double thisy = *(double *)(y->data + i*y->strides[0]);
1293-
if (MPL_isnan64(thisx) || MPL_isnan64(thisy)) {
1259+
if (isnan(thisx) || isnan(thisy)) {
12941260
if (returnMask) {
12951261
*(unsigned char *)(retmask->data + i*retmask->strides[0]) = 0;
12961262
}
1297-
double MPLnan; // don't require C99 math features - find our own nan
1298-
if (MPL_isnan64(thisx)) {
1299-
MPLnan=thisx;
1263+
double MPL_not_finite; // don't require C99 math features - find our own nan
1264+
if (isnan(thisx)) {
1265+
MPL_not_finite=thisx;
13001266
} else {
1301-
MPLnan=thisy;
1267+
MPL_not_finite=thisy;
13021268
}
1303-
*(double *)(retx->data + i*retx->strides[0]) = MPLnan;
1304-
*(double *)(rety->data + i*rety->strides[0]) = MPLnan;
1269+
*(double *)(retx->data + i*retx->strides[0]) = MPL_not_finite;
1270+
*(double *)(rety->data + i*rety->strides[0]) = MPL_not_finite;
13051271
} else {
13061272
try {
13071273
this->nonlinear_only_api(&thisx, &thisy);

0 commit comments

Comments
 (0)