Skip to content

Commit 041fd74

Browse files
committed
BLD: cross-platform inline attribute, MSVC fix with pointer arithmetic, re #458 and #460
1 parent 825ef45 commit 041fd74

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

pandas/src/numpy_helper.h

+18-7
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
11
#include "Python.h"
22
#include "numpy/ndarrayobject.h"
33

4-
inline int
4+
#ifndef PANDAS_INLINE
5+
#if defined(__GNUC__)
6+
#define PANDAS_INLINE __inline__
7+
#elif defined(_MSC_VER)
8+
#define PANDAS_INLINE __inline
9+
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
10+
#define PANDAS_INLINE inline
11+
#else
12+
#define PANDAS_INLINE
13+
#endif
14+
#endif
15+
16+
PANDAS_INLINE int
517
is_integer_object(PyObject* obj) {
618
return PyArray_IsIntegerScalar(obj);
719
}
820

9-
inline int
21+
PANDAS_INLINE int
1022
is_float_object(PyObject* obj) {
1123
return (PyFloat_Check(obj) || PyArray_IsScalar(obj, Floating));
1224
}
1325

14-
inline int
26+
PANDAS_INLINE int
1527
is_bool_object(PyObject* obj) {
1628
return (PyBool_Check(obj) || PyArray_IsScalar(obj, Bool));
1729
}
1830

19-
inline int
31+
PANDAS_INLINE int
2032
is_string_object(PyObject* obj) {
2133
return (PyString_Check(obj) || PyUnicode_Check(obj));
2234
}
2335

24-
inline int
36+
PANDAS_INLINE int
2537
assign_value_1d(PyArrayObject* ap, Py_ssize_t _i, PyObject* v) {
26-
char *item;
2738
npy_intp i = (npy_intp) _i;
28-
item = PyArray_DATA(ap) + i * PyArray_STRIDE(ap, 0);
39+
char *item = (char *) PyArray_DATA(ap) + i * PyArray_STRIDE(ap, 0);
2940
return PyArray_DESCR(ap)->f->setitem(v, item, ap);
3041
}

pandas/tests/test_frame.py

+3
Original file line numberDiff line numberDiff line change
@@ -2038,6 +2038,9 @@ def test_append_series(self):
20382038
ignore_index=True)
20392039
assert_frame_equal(result, expected)
20402040

2041+
# can append when name set
2042+
2043+
20412044
def test_append_different_columns(self):
20422045
df = DataFrame({'bools' : np.random.randn(10) > 0,
20432046
'ints' : np.random.randint(0, 10, 10),

0 commit comments

Comments
 (0)