Skip to content
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
13 changes: 4 additions & 9 deletions cpp/src/arrow/python/numpy_convert.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@
namespace arrow {
namespace py {

bool is_contiguous(PyObject* array) {
if (PyArray_Check(array)) {
return (PyArray_FLAGS(reinterpret_cast<PyArrayObject*>(array)) &
(NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_F_CONTIGUOUS)) != 0;
} else {
return false;
}
}

NumPyBuffer::NumPyBuffer(PyObject* ao) : Buffer(nullptr, 0) {
PyAcquireGIL lock;
arr_ = ao;
Expand Down Expand Up @@ -73,6 +64,8 @@ NumPyBuffer::~NumPyBuffer() {
*out = FACTORY(); \
break;

namespace {

Status GetTensorType(PyObject* dtype, std::shared_ptr<DataType>* out) {
if (!PyArray_DescrCheck(dtype)) {
return Status::TypeError("Did not pass numpy.dtype object");
Expand Down Expand Up @@ -127,6 +120,8 @@ Status GetNumPyType(const DataType& type, int* type_num) {
return Status::OK();
}

} // namespace

Status NumPyDtypeToArrow(PyObject* dtype, std::shared_ptr<DataType>* out) {
if (!PyArray_DescrCheck(dtype)) {
return Status::TypeError("Did not pass numpy.dtype object");
Expand Down
10 changes: 0 additions & 10 deletions cpp/src/arrow/python/numpy_convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,11 @@ class ARROW_PYTHON_EXPORT NumPyBuffer : public Buffer {
PyObject* arr_;
};

// Handle misbehaved types like LONGLONG and ULONGLONG
ARROW_PYTHON_EXPORT
int cast_npy_type_compat(int type_num);

ARROW_PYTHON_EXPORT
bool is_contiguous(PyObject* array);

ARROW_PYTHON_EXPORT
Status NumPyDtypeToArrow(PyObject* dtype, std::shared_ptr<DataType>* out);
ARROW_PYTHON_EXPORT
Status NumPyDtypeToArrow(PyArray_Descr* descr, std::shared_ptr<DataType>* out);

Status GetTensorType(PyObject* dtype, std::shared_ptr<DataType>* out);
Status GetNumPyType(const DataType& type, int* type_num);

ARROW_PYTHON_EXPORT Status NdarrayToTensor(MemoryPool* pool, PyObject* ao,
const std::vector<std::string>& dim_names,
std::shared_ptr<Tensor>* out);
Expand Down