Skip to content

ujson remove link dependence on npymath #1371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pandas/src/ujson/lib/ultrajson.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ Dictates and limits how much stack space for buffers UltraJSON will use before r
typedef __int64 JSINT64;
typedef unsigned __int64 JSUINT64;

#ifndef __MINGW32__
typedef unsigned __int32 uint32_t;
#endif
typedef __int32 JSINT32;
typedef uint32_t JSUINT32;
typedef unsigned __int8 JSUINT8;
Expand Down
18 changes: 1 addition & 17 deletions pandas/src/ujson/python/objToJSON.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include "py_defines.h"
#include <numpy/arrayobject.h>
#include <numpy/npy_math.h>
#include <np_datetime.h>
#include <numpy/halffloat.h>
#include <stdio.h>
#include <datetime.h>
#include <ultrajson.h>
Expand Down Expand Up @@ -138,15 +138,6 @@ static void *PyLongToINT64(JSOBJ _obj, JSONTypeContext *tc, void *outValue, size
return NULL;
}

static void *NpyHalfToDOUBLE(JSOBJ _obj, JSONTypeContext *tc, void *outValue, size_t *_outLen)
{
PyObject *obj = (PyObject *) _obj;
unsigned long ctype;
PyArray_ScalarAsCtype(obj, &ctype);
*((double *) outValue) = npy_half_to_double (ctype);
return NULL;
}

static void *NpyFloatToDOUBLE(JSOBJ _obj, JSONTypeContext *tc, void *outValue, size_t *_outLen)
{
PyObject *obj = (PyObject *) _obj;
Expand Down Expand Up @@ -1145,13 +1136,6 @@ void Object_beginTypeContext (JSOBJ _obj, JSONTypeContext *tc)
return;
}
else
if (PyArray_IsScalar(obj, Half))
{
PRINTMARK();
pc->PyTypeToJSON = NpyHalfToDOUBLE; tc->type = JT_DOUBLE;
return;
}
else
if (PyArray_IsScalar(obj, Datetime))
{
PRINTMARK();
Expand Down
10 changes: 0 additions & 10 deletions pandas/tests/test_ujson.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,6 @@ def testFloat(self):
num = np.float(256.2013)
self.assertEqual(np.float(ujson.decode(ujson.encode(num))), num)

num = np.float16(256.2013)
self.assertEqual(np.float16(ujson.decode(ujson.encode(num))), num)

num = np.float32(256.2013)
self.assertEqual(np.float32(ujson.decode(ujson.encode(num))), num)

Expand All @@ -820,17 +817,10 @@ def testFloatArray(self):
outp = np.array(ujson.decode(ujson.encode(inpt, double_precision=15)), dtype=dtype)
assert_array_almost_equal_nulp(inpt, outp)

inpt = np.arange(1.5, 21.5, 0.2, dtype=np.float16)
outp = np.array(ujson.decode(ujson.encode(inpt)), dtype=np.float16)
assert_array_almost_equal_nulp(inpt, outp)

def testFloatMax(self):
num = np.float(np.finfo(np.float).max/10)
assert_approx_equal(np.float(ujson.decode(ujson.encode(num))), num, 15)

num = np.float16(np.finfo(np.float16).max/10)
assert_approx_equal(np.float16(ujson.decode(ujson.encode(num))), num, 15)

num = np.float32(np.finfo(np.float32).max/10)
assert_approx_equal(np.float32(ujson.decode(ujson.encode(num))), num, 15)

Expand Down
11 changes: 0 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@
msg = "pandas requires NumPy >= 1.6 due to datetime64 dependency"
sys.exit(msg)

from numpy.distutils.misc_util import get_pkg_info, get_info

from distutils.extension import Extension
from distutils.command.build import build
from distutils.command.build_ext import build_ext
Expand Down Expand Up @@ -378,11 +376,6 @@ def srcpath(name=None, suffix='.pyx', subdir='src'):
sources=[srcpath('sparse', suffix=suffix)],
include_dirs=[np.get_include()])

npymath_info = get_info('npymath')

npymath_libdir = npymath_info['library_dirs'][0]
npymath_libdir = npymath_libdir.replace('\\\\', '\\')

ujson_ext = Extension('pandas._ujson',
sources=['pandas/src/ujson/python/ujson.c',
'pandas/src/ujson/python/objToJSON.c',
Expand All @@ -395,10 +388,6 @@ def srcpath(name=None, suffix='.pyx', subdir='src'):
'pandas/src/ujson/lib',
'pandas/src/datetime',
np.get_include()],
libraries=['npymath'],
library_dirs=[npymath_libdir],
# extra_link_args=[get_pkg_info('npymath').libs()]
#extra_info=get_info('npymath')
)

sandbox_ext = Extension('pandas._sandbox',
Expand Down