Commit d0b2abc
authored
fix: avoid deprecated unitless operations for NumPy 2.5 compatibility (#17589)
As per https://numpy.org/devdocs/release/2.5.0-notes.html, using the
generic unit in `numpy.timedelta64` is 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)
```
2026-06-26T22:39:25.0532625Z ==================================== ERRORS ====================================
2026-06-26T22:39:25.0533378Z __________________ ERROR collecting tests/unit/test_arrow.py ___________________
2026-06-26T22:39:25.0533991Z tests/unit/test_arrow.py:24: in <module>
2026-06-26T22:39:25.0534413Z import db_dtypes
2026-06-26T22:39:25.0534767Z db_dtypes/__init__.py:30: in <module>
2026-06-26T22:39:25.0535219Z from db_dtypes import core
2026-06-26T22:39:25.0536530Z db_dtypes/core.py:46: in <module>
2026-06-26T22:39:25.0537237Z class BaseDatetimeArray(pandas_backports.OpsMixin, _mixins.NDArrayBackedExtensionArray):
2026-06-26T22:39:25.0537974Z db_dtypes/core.py:51: in BaseDatetimeArray
2026-06-26T22:39:25.0538450Z _internal_fill_value = numpy.datetime64("NaT")
2026-06-26T22:39:25.0538897Z ^^^^^^^^^^^^^^^^^^^^^^^
2026-06-26T22:39:25.0540172Z E DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead.
2026-06-26T22:39:25.0541561Z ___________________ ERROR collecting tests/unit/test_date.py ___________________
2026-06-26T22:39:25.0542129Z tests/unit/test_date.py:25: in <module>
2026-06-26T22:39:25.0542500Z import db_dtypes
2026-06-26T22:39:25.0542818Z db_dtypes/__init__.py:30: in <module>
2026-06-26T22:39:25.0543197Z from db_dtypes import core
2026-06-26T22:39:25.0543563Z db_dtypes/core.py:46: in <module>
2026-06-26T22:39:25.0544218Z class BaseDatetimeArray(pandas_backports.OpsMixin, _mixins.NDArrayBackedExtensionArray):
2026-06-26T22:39:25.0545002Z db_dtypes/core.py:51: in BaseDatetimeArray
2026-06-26T22:39:25.0545474Z _internal_fill_value = numpy.datetime64("NaT")
2026-06-26T22:39:25.0546102Z ^^^^^^^^^^^^^^^^^^^^^^^
2026-06-26T22:39:25.0547340Z E DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead.
2026-06-26T22:39:25.0548760Z ___________________ ERROR collecting tests/unit/test_json.py ___________________
2026-06-26T22:39:25.0549293Z tests/unit/test_json.py:22: in <module>
2026-06-26T22:39:25.0549664Z import db_dtypes
2026-06-26T22:39:25.0549980Z db_dtypes/__init__.py:30: in <module>
2026-06-26T22:39:25.0550363Z from db_dtypes import core
2026-06-26T22:39:25.0550720Z db_dtypes/core.py:46: in <module>
2026-06-26T22:39:25.0551394Z class BaseDatetimeArray(pandas_backports.OpsMixin, _mixins.NDArrayBackedExtensionArray):
2026-06-26T22:39:25.0552080Z db_dtypes/core.py:51: in BaseDatetimeArray
2026-06-26T22:39:25.0552528Z _internal_fill_value = numpy.datetime64("NaT")
2026-06-26T22:39:25.0552958Z ^^^^^^^^^^^^^^^^^^^^^^^
2026-06-26T22:39:25.0554405Z E DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead.
2026-06-26T22:39:25.0555740Z _____________ ERROR collecting tests/unit/test_pandas_backports.py _____________
2026-06-26T22:39:25.0556539Z tests/unit/test_pandas_backports.py:18: in <module>
2026-06-26T22:39:25.0557049Z import db_dtypes.pandas_backports as pandas_backports
2026-06-26T22:39:25.0557498Z db_dtypes/__init__.py:30: in <module>
2026-06-26T22:39:25.0557873Z from db_dtypes import core
2026-06-26T22:39:25.0558234Z db_dtypes/core.py:46: in <module>
2026-06-26T22:39:25.0558863Z class BaseDatetimeArray(pandas_backports.OpsMixin, _mixins.NDArrayBackedExtensionArray):
2026-06-26T22:39:25.0559525Z db_dtypes/core.py:51: in BaseDatetimeArray
2026-06-26T22:39:25.0559977Z _internal_fill_value = numpy.datetime64("NaT")
2026-06-26T22:39:25.0560384Z ^^^^^^^^^^^^^^^^^^^^^^^
2026-06-26T22:39:25.0561598Z E DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead.
2026-06-26T22:39:25.0562922Z ___________________ ERROR collecting tests/unit/test_time.py ___________________
2026-06-26T22:39:25.0563453Z tests/unit/test_time.py:22: in <module>
2026-06-26T22:39:25.0563840Z import db_dtypes # noqa
2026-06-26T22:39:25.0564160Z ^^^^^^^^^^^^^^^^
2026-06-26T22:39:25.0564460Z db_dtypes/__init__.py:30: in <module>
2026-06-26T22:39:25.0565066Z from db_dtypes import core
2026-06-26T22:39:25.0565406Z db_dtypes/core.py:46: in <module>
2026-06-26T22:39:25.0566176Z class BaseDatetimeArray(pandas_backports.OpsMixin, _mixins.NDArrayBackedExtensionArray):
2026-06-26T22:39:25.0566858Z db_dtypes/core.py:51: in BaseDatetimeArray
2026-06-26T22:39:25.0567282Z _internal_fill_value = numpy.datetime64("NaT")
2026-06-26T22:39:25.0567695Z ^^^^^^^^^^^^^^^^^^^^^^^
2026-06-26T22:39:25.0568851Z E DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead.
2026-06-26T22:39:25.0570116Z =========================== short test summary info ============================
2026-06-26T22:39:25.0571523Z ERROR tests/unit/test_arrow.py - DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead.
2026-06-26T22:39:25.0573906Z ERROR tests/unit/test_date.py - DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead.
2026-06-26T22:39:25.0576196Z ERROR tests/unit/test_json.py - DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead.
2026-06-26T22:39:25.0578467Z ERROR tests/unit/test_pandas_backports.py - DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead.
2026-06-26T22:39:25.0580766Z ERROR tests/unit/test_time.py - DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`).Please use a specific unit instead.
```1 parent 8b359e2 commit d0b2abc
3 files changed
Lines changed: 68 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| |||
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
| 253 | + | |
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
393 | 394 | | |
394 | 395 | | |
395 | 396 | | |
| 397 | + | |
396 | 398 | | |
397 | 399 | | |
398 | 400 | | |
| |||
416 | 418 | | |
417 | 419 | | |
418 | 420 | | |
419 | | - | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
420 | 424 | | |
421 | 425 | | |
422 | 426 | | |
| |||
425 | 429 | | |
426 | 430 | | |
427 | 431 | | |
428 | | - | |
| 432 | + | |
429 | 433 | | |
430 | 434 | | |
431 | 435 | | |
| |||
526 | 530 | | |
527 | 531 | | |
528 | 532 | | |
529 | | - | |
530 | | - | |
531 | | - | |
532 | | - | |
533 | | - | |
534 | | - | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
535 | 554 | | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
542 | 562 | | |
543 | 563 | | |
544 | 564 | | |
| |||
547 | 567 | | |
548 | 568 | | |
549 | 569 | | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
562 | 598 | | |
563 | 599 | | |
564 | 600 | | |
| |||
0 commit comments