MCPcopy Create free account
hub / github.com/apache/arrow / set_numpy_metadata

Function set_numpy_metadata

python/pyarrow/src/arrow/python/arrow_to_pandas.cc:270–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270inline 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
288Status PyArray_NewFromPool(int nd, npy_intp* dims, PyArray_Descr* descr, MemoryPool* pool,
289 PyObject** out) {

Callers 1

MakeNumPyViewFunction · 0.85

Calls 3

NumPyFrequencyFunction · 0.85
idMethod · 0.45
unitMethod · 0.45

Tested by

no test coverage detected