fix: avoid deprecated unitless operations for NumPy 2.5 compatibility#17589
fix: avoid deprecated unitless operations for NumPy 2.5 compatibility#17589parthea wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates db-dtypes to explicitly specify the nanosecond ("ns") unit for numpy.datetime64 initializations and dynamically aligns the epoch's dtype with the target array's dtype during timedelta calculations. The review feedback suggests simplifying the epoch alignment in both astype and __add__ by directly casting _NPEPOCH to the target array's dtype instead of manually extracting the datetime unit.
e72a566 to
edd3bf9
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request updates db-dtypes to explicitly specify the "ns" unit for numpy.datetime64 epoch and NaT initializations, and casts the epoch to match the array's dtype during subtraction. The feedback highlights potential unit mismatches: hardcoding "ns" for _internal_fill_value in the base class BaseDatetimeArray can cause issues for subclasses like DateArray (which uses "D"), and returning "ns" NaT in _datetime may also conflict with DateArray's underlying storage unit.
fc8eb0f to
2e543ac
Compare
2e543ac to
086356e
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses numpy unit mismatches by dynamically determining the resolution unit for _internal_fill_value and matching the epoch's dtype with the array's dtype during subtraction. Additionally, it updates coverage settings and adds a unit test for the fallback behavior of _internal_fill_value. The review feedback highlights a potential regression in astype where casting the epoch could result in returning day-resolution deltas instead of the requested nanosecond-resolution deltas, and suggests using the local ndarray variable in _internal_fill_value to avoid redundant attribute lookups.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
As per https://numpy.org/devdocs/release/2.5.0-notes.html, using the generic unit in
numpy.timedelta64is deprecated since this can lead to unexpected behavior such as non-transitive comparison.This should fix the following errors (since warnings are treated as errors when testing)