| 257 | } |
| 258 | |
| 259 | inline void set_numpy_metadata(int type, const DataType* datatype, PyArray_Descr* out) { |
| 260 | auto metadata = |
| 261 | reinterpret_cast<PyArray_DatetimeDTypeMetaData*>(PyDataType_C_METADATA(out)); |
| 262 | if (type == NPY_DATETIME) { |
| 263 | if (datatype->id() == Type::TIMESTAMP) { |
| 264 | const auto& timestamp_type = checked_cast<const TimestampType&>(*datatype); |
| 265 | metadata->meta.base = internal::NumPyFrequency(timestamp_type.unit()); |
| 266 | } else { |
| 267 | ARROW_DCHECK(false) |
| 268 | << "NPY_DATETIME views only supported for Arrow TIMESTAMP types"; |
| 269 | } |
| 270 | } else if (type == NPY_TIMEDELTA) { |
| 271 | ARROW_DCHECK_EQ(datatype->id(), Type::DURATION); |
| 272 | const auto& duration_type = checked_cast<const DurationType&>(*datatype); |
| 273 | metadata->meta.base = internal::NumPyFrequency(duration_type.unit()); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | Status PyArray_NewFromPool(int nd, npy_intp* dims, PyArray_Descr* descr, MemoryPool* pool, |
| 278 | PyObject** out) { |
no test coverage detected