blob: 453925ae645fa45810711d02d148b82e2fcd3c17 [file] [log] [blame] [edit]
diff --git a/pandas/__init__.py b/pandas/__init__.py
--- a/pandas/__init__.py
+++ b/pandas/__init__.py
@@ -3,7 +3,7 @@
__docformat__ = 'restructuredtext'
try:
- from . import hashtable, tslib, lib
+ import hashtable, tslib, lib
except Exception: # pragma: no cover
import sys
e = sys.exc_info()[1] # Py25 and Py3 current exception syntax conflict
@@ -15,6 +15,8 @@ except Exception: # pragma: no cover
else:
raise
+import compat
+import core
from datetime import datetime
import numpy as np
diff --git a/pandas/io/packers.py b/pandas/io/packers.py
--- a/pandas/io/packers.py
+++ b/pandas/io/packers.py
@@ -60,7 +60,11 @@ from pandas.io.common import get_filepath_or_buffer
from pandas.core.internals import BlockManager, make_block
import pandas.core.internals as internals
-from pandas.msgpack import Unpacker as _Unpacker, Packer as _Packer
+try:
+ from pandas.msgpack import Unpacker as _Unpacker, Packer as _Packer
+except ImportError:
+ _Unpacker = object
+ _Packer = object
import zlib
try:
diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py
--- a/pandas/io/parsers.py
+++ b/pandas/io/parsers.py
@@ -22,7 +22,7 @@ from pandas.util.decorators import Appender
import pandas.lib as lib
import pandas.tslib as tslib
-import pandas.parser as _parser
+import pandas.p_parser as _parser
_parser_params = """Also supports optionally iterating or breaking of the file
diff --git a/pandas/io/tests/test_cparser.py b/pandas/io/tests/test_cparser.py
--- a/pandas/io/tests/test_cparser.py
+++ b/pandas/io/tests/test_cparser.py
@@ -27,8 +27,8 @@ from pandas.lib import Timestamp
import pandas.util.testing as tm
-from pandas.parser import TextReader
-import pandas.parser as parser
+from pandas.p_parser import TextReader
+import pandas.p_parser as parser
class TestCParser(tm.TestCase):
diff --git a/pandas/io/tests/test_parsers.py b/pandas/io/tests/test_parsers.py
--- a/pandas/io/tests/test_parsers.py
+++ b/pandas/io/tests/test_parsers.py
@@ -35,7 +35,7 @@ import pandas.tseries.tools as tools
from numpy.testing.decorators import slow
from numpy.testing import assert_array_equal
-from pandas.parser import OverflowError
+from pandas.p_parser import OverflowError
class ParserTests(object):
diff --git a/pandas/src/datetime.pxd b/pandas/src/datetime.pxd
--- a/pandas/src/datetime.pxd
+++ b/pandas/src/datetime.pxd
@@ -65,6 +65,7 @@ cdef extern from "numpy/npy_common.h":
ctypedef unsigned char npy_bool
cdef extern from "datetime/np_datetime.h":
+ # Note that for static linking we prefix these
ctypedef enum PANDAS_DATETIMEUNIT:
PANDAS_FR_Y
@@ -89,10 +90,12 @@ cdef extern from "datetime/np_datetime.h":
int cmp_pandas_datetimestruct(pandas_datetimestruct *a,
pandas_datetimestruct *b)
- int convert_pydatetime_to_datetimestruct(PyObject *obj,
+ int convert_pydatetime_to_datetimestruct \
+ "pandas_convert_pydatetime_to_datetimestruct" (
+ PyObject *obj,
pandas_datetimestruct *out,
PANDAS_DATETIMEUNIT *out_bestunit,
- int apply_tzinfo)
+ int apply_tzinfo)
npy_datetime pandas_datetimestruct_to_datetime(PANDAS_DATETIMEUNIT fr,
pandas_datetimestruct *d)
@@ -101,22 +104,22 @@ cdef extern from "datetime/np_datetime.h":
pandas_datetimestruct *result)
int days_per_month_table[2][12]
- int dayofweek(int y, int m, int d)
- int is_leapyear(int64_t year)
- PANDAS_DATETIMEUNIT get_datetime64_unit(object o)
+ int dayofweek "pandas_dayofweek" (int y, int m, int d)
+ int is_leapyear "pandas_is_leapyear" (int64_t year)
+ PANDAS_DATETIMEUNIT get_datetime64_unit "pandas_get_datetime64_unit" (object o)
cdef extern from "datetime/np_datetime_strings.h":
- int parse_iso_8601_datetime(char *str, int len, PANDAS_DATETIMEUNIT unit,
+ int pandas_parse_iso_8601_datetime(char *str, int len, PANDAS_DATETIMEUNIT unit,
NPY_CASTING casting, pandas_datetimestruct *out,
npy_bool *out_local, PANDAS_DATETIMEUNIT *out_bestunit,
npy_bool *out_special)
- int make_iso_8601_datetime(pandas_datetimestruct *dts, char *outstr, int outlen,
+ int pandas_make_iso_8601_datetime(pandas_datetimestruct *dts, char *outstr, int outlen,
int local, PANDAS_DATETIMEUNIT base, int tzoffset,
NPY_CASTING casting)
- int get_datetime_iso_8601_strlen(int local, PANDAS_DATETIMEUNIT base)
+ int pandas_get_datetime_iso_8601_strlen(int local, PANDAS_DATETIMEUNIT base)
# int parse_python_string(object obj, pandas_datetimestruct *out) except -1
@@ -143,7 +146,7 @@ cdef inline int _cstring_to_dts(char *val, int length,
PANDAS_DATETIMEUNIT out_bestunit
int result
- result = parse_iso_8601_datetime(val, length, PANDAS_FR_ns,
+ result = pandas_parse_iso_8601_datetime(val, length, PANDAS_FR_ns,
NPY_UNSAFE_CASTING,
dts, &islocal, &out_bestunit, &special)
return result
diff --git a/pandas/src/datetime/np_datetime.c b/pandas/src/datetime/np_datetime.c
--- a/pandas/src/datetime/np_datetime.c
+++ b/pandas/src/datetime/np_datetime.c
@@ -44,7 +44,7 @@ const int days_per_month_table[2][12] = {
/*
* Returns 1 if the given year is a leap year, 0 otherwise.
*/
-int is_leapyear(npy_int64 year)
+int pandas_is_leapyear(npy_int64 year)
{
return (year & 0x3) == 0 && /* year % 4 == 0 */
((year % 100) != 0 ||
@@ -54,7 +54,7 @@ int is_leapyear(npy_int64 year)
/*
* Sakamoto's method, from wikipedia
*/
-int dayofweek(int y, int m, int d)
+int pandas_dayofweek(int y, int m, int d)
{
int day;
static const int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
@@ -69,7 +69,7 @@ int dayofweek(int y, int m, int d)
* the current values are valid.g
*/
void
-add_minutes_to_datetimestruct(pandas_datetimestruct *dts, int minutes)
+pandas_add_minutes_to_datetimestruct(pandas_datetimestruct *dts, int minutes)
{
int isleap;
@@ -121,7 +121,7 @@ add_minutes_to_datetimestruct(pandas_datetimestruct *dts, int minutes)
* Calculates the days offset from the 1970 epoch.
*/
npy_int64
-get_datetimestruct_days(const pandas_datetimestruct *dts)
+pandas_get_datetimestruct_days(const pandas_datetimestruct *dts)
{
int i, month;
npy_int64 year, days = 0;
@@ -227,7 +227,7 @@ days_to_yearsdays(npy_int64 *days_)
* the current values are valid.
*/
NPY_NO_EXPORT void
-add_seconds_to_datetimestruct(pandas_datetimestruct *dts, int seconds)
+pandas_add_seconds_to_datetimestruct(pandas_datetimestruct *dts, int seconds)
{
int minutes;
@@ -239,12 +239,12 @@ add_seconds_to_datetimestruct(pandas_datetimestruct *dts, int seconds)
--minutes;
dts->sec += 60;
}
- add_minutes_to_datetimestruct(dts, minutes);
+ pandas_add_minutes_to_datetimestruct(dts, minutes);
}
else if (dts->sec >= 60) {
minutes = dts->sec / 60;
dts->sec = dts->sec % 60;
- add_minutes_to_datetimestruct(dts, minutes);
+ pandas_add_minutes_to_datetimestruct(dts, minutes);
}
}
@@ -356,7 +356,7 @@ cmp_pandas_datetimestruct(pandas_datetimestruct *a, pandas_datetimestruct *b)
* if obj doesn't have the neeeded date or datetime attributes.
*/
int
-convert_pydatetime_to_datetimestruct(PyObject *obj, pandas_datetimestruct *out,
+pandas_convert_pydatetime_to_datetimestruct(PyObject *obj, pandas_datetimestruct *out,
PANDAS_DATETIMEUNIT *out_bestunit,
int apply_tzinfo)
{
@@ -527,7 +527,7 @@ convert_pydatetime_to_datetimestruct(PyObject *obj, pandas_datetimestruct *out,
/* Convert to a minutes offset and apply it */
minutes_offset = seconds_offset / 60;
- add_minutes_to_datetimestruct(out, -minutes_offset);
+ pandas_add_minutes_to_datetimestruct(out, -minutes_offset);
}
}
@@ -560,7 +560,7 @@ npy_datetime pandas_datetimestruct_to_datetime(PANDAS_DATETIMEUNIT fr, pandas_da
meta.base = fr;
meta.num = 1;
- convert_datetimestruct_to_datetime(&meta, d, &result);
+ pandas_convert_datetimestruct_to_datetime(&meta, d, &result);
return result;
}
@@ -572,10 +572,10 @@ void pandas_datetime_to_datetimestruct(npy_datetime val, PANDAS_DATETIMEUNIT fr,
meta.base = fr;
meta.num = 1;
- convert_datetime_to_datetimestruct(&meta, val, result);
+ pandas_convert_datetime_to_datetimestruct(&meta, val, result);
}
-PANDAS_DATETIMEUNIT get_datetime64_unit(PyObject *obj) {
+PANDAS_DATETIMEUNIT pandas_get_datetime64_unit(PyObject *obj) {
return ((PyDatetimeScalarObject *) obj)->obmeta.base;
}
@@ -589,7 +589,7 @@ PANDAS_DATETIMEUNIT get_datetime64_unit(PyObject *obj) {
* Returns 0 on success, -1 on failure.
*/
int
-convert_datetimestruct_to_datetime(pandas_datetime_metadata *meta,
+pandas_convert_datetimestruct_to_datetime(pandas_datetime_metadata *meta,
const pandas_datetimestruct *dts,
npy_datetime *out)
{
@@ -606,7 +606,7 @@ convert_datetimestruct_to_datetime(pandas_datetime_metadata *meta,
}
else {
/* Otherwise calculate the number of days to start */
- npy_int64 days = get_datetimestruct_days(dts);
+ npy_int64 days = pandas_get_datetimestruct_days(dts);
switch (base) {
case PANDAS_FR_W:
@@ -717,7 +717,7 @@ convert_datetimestruct_to_datetime(pandas_datetime_metadata *meta,
* months units, and all the other units.
*/
npy_bool
-can_cast_timedelta64_units(PANDAS_DATETIMEUNIT src_unit,
+pandas_can_cast_timedelta64_units(PANDAS_DATETIMEUNIT src_unit,
PANDAS_DATETIMEUNIT dst_unit,
NPY_CASTING casting)
{
@@ -757,7 +757,7 @@ can_cast_timedelta64_units(PANDAS_DATETIMEUNIT src_unit,
* for all but 'unsafe' casting.
*/
npy_bool
-can_cast_datetime64_units(PANDAS_DATETIMEUNIT src_unit,
+pandas_can_cast_datetime64_units(PANDAS_DATETIMEUNIT src_unit,
PANDAS_DATETIMEUNIT dst_unit,
NPY_CASTING casting)
{
@@ -794,7 +794,7 @@ can_cast_datetime64_units(PANDAS_DATETIMEUNIT src_unit,
* Converts a datetime based on the given metadata into a datetimestruct
*/
int
-convert_datetime_to_datetimestruct(pandas_datetime_metadata *meta,
+pandas_convert_datetime_to_datetimestruct(pandas_datetime_metadata *meta,
npy_datetime dt,
pandas_datetimestruct *out)
{
@@ -973,7 +973,7 @@ convert_datetime_to_datetimestruct(pandas_datetime_metadata *meta,
--minutes;
}
/* Offset the negative minutes */
- add_minutes_to_datetimestruct(out, minutes);
+ pandas_add_minutes_to_datetimestruct(out, minutes);
out->sec = (dt / 1000000000000000LL) % 60;
out->us = (dt / 1000000000LL) % 1000000LL;
out->ps = (dt / 1000LL) % 1000000LL;
@@ -999,7 +999,7 @@ convert_datetime_to_datetimestruct(pandas_datetime_metadata *meta,
--seconds;
}
/* Offset the negative seconds */
- add_seconds_to_datetimestruct(out, seconds);
+ pandas_add_seconds_to_datetimestruct(out, seconds);
out->us = (dt / 1000000000000LL) % 1000000LL;
out->ps = (dt / 1000000LL) % 1000000LL;
out->as = dt % 1000000LL;
diff --git a/pandas/src/datetime/np_datetime.h b/pandas/src/datetime/np_datetime.h
--- a/pandas/src/datetime/np_datetime.h
+++ b/pandas/src/datetime/np_datetime.h
@@ -45,7 +45,7 @@ typedef struct {
// stuff pandas needs
// ----------------------------------------------------------------------------
-int convert_pydatetime_to_datetimestruct(PyObject *obj, pandas_datetimestruct *out,
+int pandas_convert_pydatetime_to_datetimestruct(PyObject *obj, pandas_datetimestruct *out,
PANDAS_DATETIMEUNIT *out_bestunit,
int apply_tzinfo);
@@ -55,14 +55,14 @@ npy_datetime pandas_datetimestruct_to_datetime(PANDAS_DATETIMEUNIT fr,
void pandas_datetime_to_datetimestruct(npy_datetime val, PANDAS_DATETIMEUNIT fr,
pandas_datetimestruct *result);
-int dayofweek(int y, int m, int d);
+int pandas_dayofweek(int y, int m, int d);
extern const int days_per_month_table[2][12];
// stuff numpy-derived code needs in header
// ----------------------------------------------------------------------------
-int is_leapyear(npy_int64 year);
+int pandas_is_leapyear(npy_int64 year);
/*
* Converts a datetime from a datetimestruct to a datetime based
@@ -73,7 +73,7 @@ int is_leapyear(npy_int64 year);
* Returns 0 on success, -1 on failure.
*/
int
-convert_datetimestruct_to_datetime(pandas_datetime_metadata *meta,
+pandas_convert_datetimestruct_to_datetime(pandas_datetime_metadata *meta,
const pandas_datetimestruct *dts,
npy_datetime *out);
@@ -81,14 +81,14 @@ convert_datetimestruct_to_datetime(pandas_datetime_metadata *meta,
* Calculates the days offset from the 1970 epoch.
*/
npy_int64
-get_datetimestruct_days(const pandas_datetimestruct *dts);
+pandas_get_datetimestruct_days(const pandas_datetimestruct *dts);
/*
* Adjusts a datetimestruct based on a minutes offset. Assumes
* the current values are valid.
*/
void
-add_minutes_to_datetimestruct(pandas_datetimestruct *dts, int minutes);
+pandas_add_minutes_to_datetimestruct(pandas_datetimestruct *dts, int minutes);
/*
* This provides the casting rules for the TIMEDELTA data type units.
@@ -97,23 +97,23 @@ add_minutes_to_datetimestruct(pandas_datetimestruct *dts, int minutes);
* months units, and all the other units.
*/
//npy_bool
-//can_cast_timedelta64_units(PANDAS_DATETIMEUNIT src_unit,
+//pandas_can_cast_timedelta64_units(PANDAS_DATETIMEUNIT src_unit,
// PANDAS_DATETIMEUNIT dst_unit,
// NPY_CASTING casting);
npy_bool
-can_cast_datetime64_units(PANDAS_DATETIMEUNIT src_unit,
+pandas_can_cast_datetime64_units(PANDAS_DATETIMEUNIT src_unit,
PANDAS_DATETIMEUNIT dst_unit,
NPY_CASTING casting);
int
-convert_datetime_to_datetimestruct(pandas_datetime_metadata *meta,
+pandas_convert_datetime_to_datetimestruct(pandas_datetime_metadata *meta,
npy_datetime dt,
pandas_datetimestruct *out);
-PANDAS_DATETIMEUNIT get_datetime64_unit(PyObject *obj);
+PANDAS_DATETIMEUNIT pandas_get_datetime64_unit(PyObject *obj);
#endif
diff --git a/pandas/src/datetime/np_datetime_strings.c b/pandas/src/datetime/np_datetime_strings.c
--- a/pandas/src/datetime/np_datetime_strings.c
+++ b/pandas/src/datetime/np_datetime_strings.c
@@ -21,7 +21,7 @@
#include "np_datetime_strings.h"
NPY_NO_EXPORT const char *
-npy_casting_to_string(NPY_CASTING casting)
+pandas_npy_casting_to_string(NPY_CASTING casting)
{
switch (casting) {
case NPY_NO_CASTING:
@@ -199,7 +199,7 @@ convert_datetimestruct_utc_to_local(pandas_datetimestruct *out_dts_local,
* we drop the seconds value from the pandas_datetimestruct, everything
* is ok for this operation.
*/
- rawtime = (time_t)get_datetimestruct_days(out_dts_local) * 24 * 60 * 60;
+ rawtime = (time_t)pandas_get_datetimestruct_days(out_dts_local) * 24 * 60 * 60;
rawtime += dts_utc->hour * 60 * 60;
rawtime += dts_utc->min * 60;
@@ -217,7 +217,7 @@ convert_datetimestruct_utc_to_local(pandas_datetimestruct *out_dts_local,
/* Extract the timezone offset that was applied */
rawtime /= 60;
- localrawtime = (time_t)get_datetimestruct_days(out_dts_local) * 24 * 60;
+ localrawtime = (time_t)pandas_get_datetimestruct_days(out_dts_local) * 24 * 60;
localrawtime += out_dts_local->hour * 60;
localrawtime += out_dts_local->min;
@@ -330,7 +330,7 @@ convert_datetimestruct_local_to_utc(pandas_datetimestruct *out_dts_utc,
/* } */
/* /\* Parse the ISO date *\/ */
-/* if (parse_iso_8601_datetime(str, len, PANDAS_FR_us, NPY_UNSAFE_CASTING, */
+/* if (pandas_parse_iso_8601_datetime(str, len, PANDAS_FR_us, NPY_UNSAFE_CASTING, */
/* dts, NULL, &bestunit, NULL) < 0) { */
/* Py_DECREF(bytes); */
/* return -1; */
@@ -377,7 +377,7 @@ convert_datetimestruct_local_to_utc(pandas_datetimestruct *out_dts_utc,
* Returns 0 on success, -1 on failure.
*/
int
-parse_iso_8601_datetime(char *str, int len,
+pandas_parse_iso_8601_datetime(char *str, int len,
PANDAS_DATETIMEUNIT unit,
NPY_CASTING casting,
pandas_datetimestruct *out,
@@ -438,12 +438,12 @@ parse_iso_8601_datetime(char *str, int len,
}
/* Check the casting rule */
- if (unit != -1 && !can_cast_datetime64_units(bestunit, unit,
+ if (unit != -1 && !pandas_can_cast_datetime64_units(bestunit, unit,
casting)) {
PyErr_Format(PyExc_TypeError, "Cannot parse \"%s\" as unit "
"'%s' using casting rule %s",
str, _datetime_strings[unit],
- npy_casting_to_string(casting));
+ pandas_npy_casting_to_string(casting));
return -1;
}
@@ -481,16 +481,16 @@ parse_iso_8601_datetime(char *str, int len,
}
/* Check the casting rule */
- if (unit != -1 && !can_cast_datetime64_units(bestunit, unit,
+ if (unit != -1 && !pandas_can_cast_datetime64_units(bestunit, unit,
casting)) {
PyErr_Format(PyExc_TypeError, "Cannot parse \"%s\" as unit "
"'%s' using casting rule %s",
str, _datetime_strings[unit],
- npy_casting_to_string(casting));
+ pandas_npy_casting_to_string(casting));
return -1;
}
- return convert_datetime_to_datetimestruct(&meta, rawtime, out);
+ return pandas_convert_datetime_to_datetimestruct(&meta, rawtime, out);
}
/* Anything else isn't a special value */
@@ -872,7 +872,7 @@ parse_timezone:
offset_hour = -offset_hour;
offset_minute = -offset_minute;
}
- add_minutes_to_datetimestruct(out, -60 * offset_hour - offset_minute);
+ pandas_add_minutes_to_datetimestruct(out, -60 * offset_hour - offset_minute);
}
/* Skip trailing whitespace */
@@ -891,12 +891,12 @@ finish:
}
/* Check the casting rule */
- if (unit != -1 && !can_cast_datetime64_units(bestunit, unit,
+ if (unit != -1 && !pandas_can_cast_datetime64_units(bestunit, unit,
casting)) {
PyErr_Format(PyExc_TypeError, "Cannot parse \"%s\" as unit "
"'%s' using casting rule %s",
str, _datetime_strings[unit],
- npy_casting_to_string(casting));
+ pandas_npy_casting_to_string(casting));
return -1;
}
@@ -917,7 +917,7 @@ error:
* objects with the given local and unit settings.
*/
int
-get_datetime_iso_8601_strlen(int local, PANDAS_DATETIMEUNIT base)
+pandas_get_datetime_iso_8601_strlen(int local, PANDAS_DATETIMEUNIT base)
{
int len = 0;
@@ -1047,7 +1047,7 @@ lossless_unit_from_datetimestruct(pandas_datetimestruct *dts)
* string was too short).
*/
int
-make_iso_8601_datetime(pandas_datetimestruct *dts, char *outstr, int outlen,
+pandas_make_iso_8601_datetime(pandas_datetimestruct *dts, char *outstr, int outlen,
int local, PANDAS_DATETIMEUNIT base, int tzoffset,
NPY_CASTING casting)
{
@@ -1105,7 +1105,7 @@ make_iso_8601_datetime(pandas_datetimestruct *dts, char *outstr, int outlen,
/* Set and apply the required timezone offset */
timezone_offset = tzoffset;
- add_minutes_to_datetimestruct(dts, timezone_offset);
+ pandas_add_minutes_to_datetimestruct(dts, timezone_offset);
}
/*
diff --git a/pandas/src/datetime/np_datetime_strings.h b/pandas/src/datetime/np_datetime_strings.h
--- a/pandas/src/datetime/np_datetime_strings.h
+++ b/pandas/src/datetime/np_datetime_strings.h
@@ -41,7 +41,7 @@
* Returns 0 on success, -1 on failure.
*/
int
-parse_iso_8601_datetime(char *str, int len,
+pandas_parse_iso_8601_datetime(char *str, int len,
PANDAS_DATETIMEUNIT unit,
NPY_CASTING casting,
pandas_datetimestruct *out,
@@ -54,7 +54,7 @@ parse_iso_8601_datetime(char *str, int len,
* objects with the given local and unit settings.
*/
int
-get_datetime_iso_8601_strlen(int local, PANDAS_DATETIMEUNIT base);
+pandas_get_datetime_iso_8601_strlen(int local, PANDAS_DATETIMEUNIT base);
/*
* Converts an pandas_datetimestruct to an (almost) ISO 8601
@@ -79,7 +79,7 @@ get_datetime_iso_8601_strlen(int local, PANDAS_DATETIMEUNIT base);
* string was too short).
*/
int
-make_iso_8601_datetime(pandas_datetimestruct *dts, char *outstr, int outlen,
+pandas_make_iso_8601_datetime(pandas_datetimestruct *dts, char *outstr, int outlen,
int local, PANDAS_DATETIMEUNIT base, int tzoffset,
NPY_CASTING casting);
diff --git a/pandas/src/datetime_helper.h b/pandas/src/datetime_helper.h
--- a/pandas/src/datetime_helper.h
+++ b/pandas/src/datetime_helper.h
@@ -1,5 +1,7 @@
#include "datetime.h"
+#include "helper.h"
+PANDAS_INLINE
void mangle_nat(PyObject *val) {
PyDateTime_GET_MONTH(val) = -1;
PyDateTime_GET_DAY(val) = -1;
diff --git a/pandas/src/numpy_helper.h b/pandas/src/numpy_helper.h
--- a/pandas/src/numpy_helper.h
+++ b/pandas/src/numpy_helper.h
@@ -126,6 +126,7 @@ char_to_string(char* data) {
// return PyString_Check(obj);
// #endif
+PANDAS_INLINE
PyObject* sarr_from_data(PyArray_Descr *descr, int length, void* data) {
PyArrayObject *result;
npy_intp dims[1] = {length};
@@ -140,6 +141,7 @@ PyObject* sarr_from_data(PyArray_Descr *descr, int length, void* data) {
}
+PANDAS_INLINE
void transfer_object_column(char *dst, char *src, size_t stride,
size_t length) {
int i;
@@ -158,10 +160,12 @@ void transfer_object_column(char *dst, char *src, size_t stride,
}
}
+PANDAS_INLINE
void set_array_owndata(PyArrayObject *ao) {
ao->flags |= NPY_OWNDATA;
}
+PANDAS_INLINE
void set_array_not_contiguous(PyArrayObject *ao) {
ao->flags &= ~(NPY_C_CONTIGUOUS | NPY_F_CONTIGUOUS);
}
diff --git a/pandas/src/parse_helper.h b/pandas/src/parse_helper.h
--- a/pandas/src/parse_helper.h
+++ b/pandas/src/parse_helper.h
@@ -1,9 +1,11 @@
#include <errno.h>
#include <float.h>
+#include "helper.h"
static double xstrtod(const char *p, char **q, char decimal, char sci,
int skip_trailing);
+PANDAS_INLINE
int to_double(char *item, double *p_value, char sci, char decimal)
{
char *p_end;
diff --git a/pandas/tests/test_frame.py b/pandas/tests/test_frame.py
--- a/pandas/tests/test_frame.py
+++ b/pandas/tests/test_frame.py
@@ -37,7 +37,7 @@ from pandas.core.api import (DataFrame, Index, Series, notnull, isnull,
from pandas import date_range
import pandas as pd
from pandas.io.parsers import read_csv
-from pandas.parser import CParserError
+from pandas.p_parser import CParserError
from pandas.util.misc import is_little_endian
from pandas.util.testing import (assert_almost_equal,
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -75,6 +75,7 @@ from distutils.extension import Extension
from distutils.command.build import build
from distutils.command.sdist import sdist
from distutils.command.build_ext import build_ext as _build_ext
+from numpy.distutils.misc_util import get_numpy_include_dirs
try:
from Cython.Distutils import build_ext as _build_ext
@@ -88,11 +89,11 @@ from os.path import join as pjoin
class build_ext(_build_ext):
def build_extensions(self):
- numpy_incl = pkg_resources.resource_filename('numpy', 'core/include')
-
- for ext in self.extensions:
- if hasattr(ext, 'include_dirs') and not numpy_incl in ext.include_dirs:
- ext.include_dirs.append(numpy_incl)
+ numpy_incl_dirs = get_numpy_include_dirs()
+ for numpy_incl in numpy_incl_dirs:
+ for ext in self.extensions:
+ if hasattr(ext, 'include_dirs') and not numpy_incl in ext.include_dirs:
+ ext.include_dirs.append(numpy_incl)
_build_ext.build_extensions(self)
@@ -435,7 +436,7 @@ ext_data = dict(
'pandas/src/datetime/np_datetime_strings.c']},
algos={'pyxfile': 'algos',
'depends': [srcpath('generated', suffix='.pyx')]},
- parser=dict(pyxfile='parser',
+ p_parser=dict(pyxfile='parser',
depends=['pandas/src/parser/tokenizer.h',
'pandas/src/parser/io.h',
'pandas/src/numpy_helper.h'],
@@ -444,6 +445,8 @@ ext_data = dict(
)
extensions = []
+included = set(['pandas/src/datetime/np_datetime.c',
+ 'pandas/src/datetime/np_datetime_strings.c'])
for name, data in ext_data.items():
sources = [srcpath(data['pyxfile'], suffix=suffix, subdir='')]
@@ -451,7 +454,10 @@ for name, data in ext_data.items():
if suffix == '.pyx' and pxds:
sources.extend(pxds)
- sources.extend(data.get('sources', []))
+ for source in data.get('sources', []):
+ if source not in included:
+ included.add(source)
+ sources.append(source)
include = data.get('include', common_include)
@@ -493,7 +499,7 @@ msgpack_ext = Extension('pandas.msgpack',
include_dirs=common_include,
define_macros=macros)
-extensions.append(msgpack_ext)
+#extensions.append(msgpack_ext)
# if not ISRELEASED:
# extensions.extend([sandbox_ext])
@@ -514,7 +520,8 @@ ujson_ext = Extension('pandas.json',
'pandas/src/ujson/lib/ultrajsonenc.c',
'pandas/src/ujson/lib/ultrajsondec.c',
'pandas/src/datetime/np_datetime.c',
- 'pandas/src/datetime/np_datetime_strings.c'],
+ 'pandas/src/datetime/np_datetime_strings.c',
+ ],
include_dirs=['pandas/src/ujson/python',
'pandas/src/ujson/lib',
'pandas/src/datetime'] + common_include,