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:259–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

257}
258
259inline 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
277Status PyArray_NewFromPool(int nd, npy_intp* dims, PyArray_Descr* descr, MemoryPool* pool,
278 PyObject** out) {

Callers 1

MakeNumPyViewFunction · 0.85

Calls 3

NumPyFrequencyFunction · 0.85
idMethod · 0.45
unitMethod · 0.45

Tested by

no test coverage detected