MCPcopy Create free account
hub / github.com/numpy/numpy / can_cast_datetime64_metadata

Function can_cast_datetime64_metadata

numpy/core/src/multiarray/datetime.c:1389–1411  ·  view source on GitHub ↗

* This provides the casting rules for the DATETIME data type metadata. */

Source from the content-addressed store, hash-verified

1387 * This provides the casting rules for the DATETIME data type metadata.
1388 */
1389NPY_NO_EXPORT npy_bool
1390can_cast_datetime64_metadata(PyArray_DatetimeMetaData *src_meta,
1391 PyArray_DatetimeMetaData *dst_meta,
1392 NPY_CASTING casting)
1393{
1394 switch (casting) {
1395 case NPY_UNSAFE_CASTING:
1396 return 1;
1397
1398 case NPY_SAME_KIND_CASTING:
1399 return can_cast_datetime64_units(src_meta->base, dst_meta->base,
1400 casting);
1401
1402 case NPY_SAFE_CASTING:
1403 return can_cast_datetime64_units(src_meta->base, dst_meta->base,
1404 casting) &&
1405 datetime_metadata_divides(src_meta, dst_meta, 0);
1406
1407 default:
1408 return src_meta->base == dst_meta->base &&
1409 src_meta->num == dst_meta->num;
1410 }
1411}
1412
1413/*
1414 * This provides the casting rules for the TIMEDELTA data type metadata.

Calls 2

Tested by

no test coverage detected