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

Skip to content

Commit 2800827

Browse files
committed
revert r3512, which broke on Mac
svn path=/trunk/matplotlib/; revision=3515
1 parent c2e8848 commit 2800827

5 files changed

Lines changed: 65 additions & 23 deletions

File tree

CHANGELOG

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
numpified axes.py, and cleaned up the imports in axes.py
33
- JDH
44

5-
2007-07-13 Removed our own MPL_isnan.h in favor of numpy's
6-
implementation -ADS
7-
85
2007-07-13 Added legend.loc as configurable option that could in
96
future default to 'best'. - NN
107

setup.py

Lines changed: 3 additions & 1 deletion
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_ttconv
85+
build_subprocess, build_isnan, build_ttconv
8686
import distutils.sysconfig
8787

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

159+
build_isnan(ext_modules, packages)
160+
159161
try: import datetime
160162
except ImportError: havedate = False
161163
else: havedate = True

setupext.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,3 +809,11 @@ def build_subprocess(ext_modules, packages):
809809
)
810810
add_base_flags(module)
811811
ext_modules.append(module)
812+
813+
def build_isnan(ext_modules, packages):
814+
module = Extension(
815+
'matplotlib._isnan',
816+
[ 'src/_isnan.c'],
817+
)
818+
add_base_flags(module)
819+
ext_modules.append(module)

src/_backend_agg.cpp

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

2728
#include "swig_runtime.h"
2829

@@ -1584,7 +1585,7 @@ RendererAgg::draw_lines(const Py::Tuple& args) {
15841585
moveto = true;
15851586
continue;
15861587
}
1587-
if (isnan(thisx) || isnan(thisy)) {
1588+
if (MPL_isnan64(thisx) || MPL_isnan64(thisy)) {
15881589
moveto = true;
15891590
continue;
15901591
}

src/_transforms.cpp

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

55
#include "_transforms.h"
66
#include "mplutils.h"
7+
#include "MPL_isnan.h"
78

89

910
#include "numpy/arrayobject.h"
10-
#include "numpy/ufuncobject.h"
11-
#if !defined(isfinite)
12-
#define isfinite(x) (!(isinf((x)) || isnan((x))))
13-
#endif
11+
//#include "numpy/ufuncobject.h"
12+
13+
14+
//bool skip_float(double x) {
15+
// return !MPL_isnan64(x) && !isinf(x);
16+
//}
1417

1518
Value::~Value() {
1619
_VERBOSE("Value::~Value");
@@ -467,23 +470,31 @@ Bbox::update(const Py::Tuple &args) {
467470

468471
Py::Tuple tup;
469472
if (ignore) {
470-
minx = miny = std::numeric_limits<double>::max();
471-
maxx = maxy = std::numeric_limits<double>::min();
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;
472481
}
473482

483+
474484
for (size_t i=0; i<Nx; ++i) {
475485
tup = xys[i];
476486
double x = Py::Float(tup[0]);
477487
double y = Py::Float(tup[1]);
478-
if (isnan(x) || isnan(y)) continue;
479488
_posx.update(x);
480489
_posy.update(y);
481490
if (x<minx) minx=x;
482491
if (x>maxx) maxx=x;
483492
if (y<miny) miny=y;
484493
if (y>maxy) maxy=y;
494+
485495
}
486496

497+
487498
_ll->x_api()->set_api(minx);
488499
_ll->y_api()->set_api(miny);
489500
_ur->x_api()->set_api(maxx);
@@ -539,7 +550,7 @@ Bbox::update_numerix_xy(const Py::Tuple &args) {
539550
for (size_t i=0; i< Nxy; ++i) {
540551
thisx = *(double *)(xyin->data + i*xyin->strides[0]);
541552
thisy = *(double *)(xyin->data + i*xyin->strides[0] + xyin->strides[1]);
542-
if (isnan(thisx) || isnan(thisy)) continue;
553+
if (MPL_isnan64(thisx) || MPL_isnan64(thisy)) continue;
543554
_posx.update(thisx);
544555
_posy.update(thisy);
545556
if (thisx<minx) minx=thisx;
@@ -606,14 +617,37 @@ Bbox::update_numerix(const Py::Tuple &args) {
606617
_ignore = 0; // don't ignore future updates
607618
}
608619
if (ignore) {
609-
minx = miny = std::numeric_limits<double>::max();
610-
maxx = maxy = std::numeric_limits<double>::min();
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+
}
611645
}
612646

613647
for (size_t i=0; i< Nx; ++i) {
614648
thisx = *(double *)(x->data + i*x->strides[0]);
615649
thisy = *(double *)(y->data + i*y->strides[0]);
616-
if (isnan(thisx) || isnan(thisy)) continue;
650+
617651
_posx.update(thisx);
618652
_posy.update(thisy);
619653
if (thisx<minx) minx=thisx;
@@ -1255,18 +1289,18 @@ Transformation::nonlinear_only_numerix(const Py::Tuple & args, const Py::Dict &k
12551289

12561290
double thisx = *(double *)(x->data + i*x->strides[0]);
12571291
double thisy = *(double *)(y->data + i*y->strides[0]);
1258-
if (isnan(thisx) || isnan(thisy)) {
1292+
if (MPL_isnan64(thisx) || MPL_isnan64(thisy)) {
12591293
if (returnMask) {
12601294
*(unsigned char *)(retmask->data + i*retmask->strides[0]) = 0;
12611295
}
1262-
double MPL_not_finite; // don't require C99 math features - find our own nan
1263-
if (isnan(thisx)) {
1264-
MPL_not_finite=thisx;
1296+
double MPLnan; // don't require C99 math features - find our own nan
1297+
if (MPL_isnan64(thisx)) {
1298+
MPLnan=thisx;
12651299
} else {
1266-
MPL_not_finite=thisy;
1300+
MPLnan=thisy;
12671301
}
1268-
*(double *)(retx->data + i*retx->strides[0]) = MPL_not_finite;
1269-
*(double *)(rety->data + i*rety->strides[0]) = MPL_not_finite;
1302+
*(double *)(retx->data + i*retx->strides[0]) = MPLnan;
1303+
*(double *)(rety->data + i*rety->strides[0]) = MPLnan;
12701304
} else {
12711305
try {
12721306
this->nonlinear_only_api(&thisx, &thisy);

0 commit comments

Comments
 (0)