| 268 | } |
| 269 | |
| 270 | inline void set_numpy_metadata(int type, const DataType* datatype, PyArray_Descr* out) { |
| 271 | auto metadata = |
| 272 | reinterpret_cast<PyArray_DatetimeDTypeMetaData*>(PyDataType_C_METADATA(out)); |
| 273 | if (type == NPY_DATETIME) { |
| 274 | if (datatype->id() == Type::TIMESTAMP) { |
| 275 | const auto& timestamp_type = checked_cast<const TimestampType&>(*datatype); |
| 276 | metadata->meta.base = internal::NumPyFrequency(timestamp_type.unit()); |
| 277 | } else { |
| 278 | ARROW_DCHECK(false) |
| 279 | << "NPY_DATETIME views only supported for Arrow TIMESTAMP types"; |
| 280 | } |
| 281 | } else if (type == NPY_TIMEDELTA) { |
| 282 | ARROW_DCHECK_EQ(datatype->id(), Type::DURATION); |
| 283 | const auto& duration_type = checked_cast<const DurationType&>(*datatype); |
| 284 | metadata->meta.base = internal::NumPyFrequency(duration_type.unit()); |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | Status PyArray_NewFromPool(int nd, npy_intp* dims, PyArray_Descr* descr, MemoryPool* pool, |
| 289 | PyObject** out) { |
no test coverage detected