summaryrefslogtreecommitdiff
path: root/numpy/array_api/_typing.py
diff options
context:
space:
mode:
authorTyler Reddy <tyler.je.reddy@gmail.com>2021-10-02 18:41:31 -0600
committerGitHub <noreply@github.com>2021-10-02 19:41:31 -0500
commit3c1e9b4717b2eb33a2bf2d495006bc300f5b8765 (patch)
treecd360a7ee6e84daf97d9837e841ac3c6cbe67b01 /numpy/array_api/_typing.py
parent96d5993c4fca186f8c9f0f686c963549a03d0636 (diff)
downloadnumpy-3c1e9b4717b2eb33a2bf2d495006bc300f5b8765.tar.gz
BUG: fix time cast-safety for `factor*unit` e.g. in `10**6*ms == 1*s` (#19731)
* for `datetime64` units smaller than `s`, handle some common/reasonable "metrix prefix" casting conversions like 1000 ns == 1 us * this adds support specifically for equivalencies that span 10^3 and 10^6 fold, but there are even more beyond that, and if we want to handle them all we may want to abstract to a handler function * that said, this still seems like a solid improvement that covers some of the more common cases? * MAINT: PR 19731 revisions * add support/testing for datetime unit conversions at the scale of 10^9, when below the 32-bit integer overflow limit * raise a `TypeError` when `M8` unit magnitude exceeds `INT_MAX` * MAINT: PR 19731 revisions * add new test `test_datetime_prefix_conversions()` that performs bidirectional metric time prefix casting checks * use `long long int` for `true_meta_num` on 32-bit systems * some C code whitespace changes requested during review * MAINT: PR 19731 revisions * flake8-related fixes * MAINT: PR 19731 revisions * use a fixed size `int64_t` type for `true_meta_num` on Windows to allow the overflow check to happen properly * whitespace adjustments for the C code based on review comments * MAINT: PR 19731 revisions * improve the portability of the overflow check for datetime unit integer prefixes * MAINT: PR 19731 revisions * simplify the changes by using `NumPyOS_strtoll` (less custom C needed this way) * MAINT: cleanup after merge conflict. * MAINT: PR 19731 revisions * based on reviewer feedback, make negative datetime units a `TypeError` (including regression test)
Diffstat (limited to 'numpy/array_api/_typing.py')
0 files changed, 0 insertions, 0 deletions