| 325 | }; |
| 326 | |
| 327 | Status NumPyConverter::Convert() { |
| 328 | if (PyArray_NDIM(arr_) != 1) { |
| 329 | return Status::Invalid("only handle 1-dimensional arrays"); |
| 330 | } |
| 331 | |
| 332 | if (dtype_->type_num == NPY_OBJECT) { |
| 333 | // If an object array, convert it like a normal Python sequence |
| 334 | PyConversionOptions py_options; |
| 335 | py_options.type = type_; |
| 336 | py_options.from_pandas = from_pandas_; |
| 337 | ARROW_ASSIGN_OR_RAISE( |
| 338 | auto chunked_array, |
| 339 | ConvertPySequence(reinterpret_cast<PyObject*>(arr_), |
| 340 | reinterpret_cast<PyObject*>(mask_), py_options, pool_)); |
| 341 | out_arrays_ = chunked_array->chunks(); |
| 342 | return Status::OK(); |
| 343 | } |
| 344 | |
| 345 | if (type_ == nullptr) { |
| 346 | return Status::Invalid("Must pass data type for non-object arrays"); |
| 347 | } |
| 348 | |
| 349 | if (dtype_->type_num == NPY_VSTRING && !is_string_or_string_view(type_->id())) { |
| 350 | return Status::TypeError("Expected an Arrow string type for NumPy StringDType, got ", |
| 351 | type_->ToString()); |
| 352 | } |
| 353 | |
| 354 | // Visit the type to perform conversion |
| 355 | return VisitTypeInline(*type_, this); |
| 356 | } |
| 357 | |
| 358 | namespace { |
| 359 |
no test coverage detected