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

Skip to content

Commit 86b3cc2

Browse files
committed
add files I forgot to add in last commit
svn path=/trunk/matplotlib/; revision=3517
1 parent 7362369 commit 86b3cc2

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

src/MPL_isnan.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// These definitions modified from numarray's Include/numarray/nummacro.h
2+
3+
#if defined(SIZEOF_VOID_P)
4+
#if SIZEOF_VOID_P == 8
5+
#define MPL_LP64 1
6+
#else
7+
#define MPL_LP64 0
8+
#endif
9+
#else
10+
#define MPL_LP64 0
11+
#endif
12+
13+
#if MPL_LP64
14+
typedef long int MPL_Int64;
15+
#else /* 32-bit platforms */
16+
#if defined(_MSC_VER)
17+
typedef __int64 MPL_Int64;
18+
#else
19+
typedef long long MPL_Int64;
20+
#endif
21+
#endif
22+
23+
#if !defined(MPL_isnan64)
24+
#define MPL_U64(u) (* (MPL_Int64 *) &(u) )
25+
26+
#if !defined(_MSC_VER)
27+
#define MPL_isnan64(u) \
28+
( (( MPL_U64(u) & 0x7ff0000000000000LL) == 0x7ff0000000000000LL) && ((MPL_U64(u) & 0x000fffffffffffffLL) != 0)) ? 1:0
29+
#else
30+
#define MPL_isnan64(u) \
31+
( (( MPL_U64(u) & 0x7ff0000000000000i64) == 0x7ff0000000000000i64) && ((MPL_U64(u) & 0x000fffffffffffffi64) != 0)) ? 1:0
32+
#endif
33+
#endif /* MPL_isnan64 */

src/_isnan.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include "Python.h"
2+
#include "MPL_isnan.h"
3+
4+
static PyObject *
5+
isnan64(PyObject *self, PyObject *args)
6+
{
7+
double input;
8+
if (!PyArg_ParseTuple(args, "d",
9+
&input))
10+
return NULL;
11+
12+
if (MPL_isnan64(input)) {
13+
Py_INCREF(Py_True);
14+
return Py_True;
15+
}
16+
17+
Py_INCREF(Py_False);
18+
return Py_False;
19+
}
20+
21+
static PyMethodDef _isnan_functions[] = {
22+
{ "isnan64", (PyCFunction)isnan64, METH_VARARGS },
23+
{ NULL, NULL, 0 }
24+
};
25+
26+
DL_EXPORT(void)
27+
init_isnan(void)
28+
{
29+
PyObject *mod;
30+
mod = Py_InitModule("matplotlib._isnan",
31+
_isnan_functions);
32+
}

0 commit comments

Comments
 (0)