Repository navigation
Closed
Description
I get failures from the test test_raise_warning_for_operation_with_generic_unit in numpy/_core/tests/test_deprecations.py. The output for a run of spin test is below, but the problematic behavior is the generation of two warnings in the following:
In [1]: value0 = np.timedelta64(3, 's')
In [2]: np.subtract(value0, 5)
<ipython-input-2-2e78d8f95a84>:1: DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. Please convert the integer with an explicit unit.
np.subtract(value0, 5)
<ipython-input-2-2e78d8f95a84>:1: 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.
np.subtract(value0, 5)
Out[2]: np.timedelta64(-2,'s')
Here's a run of all the tests in test_deprecation.py that shows 8 failures. Strangely, I get only two of these failures when I run the full test suite with spin test -m full -j 12.
$ spin test -m full -j 12 -t numpy/_core/tests/test_deprecations.py
Invoking `build` prior to running tests:
$ /home/warren/py3.14.5/bin/python3.14 vendored-meson/meson/meson.py compile -C build
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /home/warren/py3.14.5/bin/ninja -C /home/warren/repos/git/forks/numpy/build
ninja: Entering directory `/home/warren/repos/git/forks/numpy/build'
[1/1] Generating numpy/generate-version with a custom command
Saving version to numpy/version.py
$ /home/warren/py3.14.5/bin/python3.14 vendored-meson/meson/meson.py install --no-rebuild --only-changed -C build --destdir ../build-install
$ export PYTHONPATH="/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages"
$ /home/warren/py3.14.5/bin/python3.14 -P -c 'import numpy'
$ cd /home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages
$ /home/warren/py3.14.5/bin/python3.14 -P -m pytest -n 12 numpy/_core/tests/test_deprecations.py
================================================== test session starts ===================================================
platform linux -- Python 3.14.5, pytest-9.1.0, pluggy-1.6.0
rootdir: /home/warren/repos/git/forks/numpy
configfile: pytest.ini
plugins: cov-7.1.0, anyio-4.13.0, timeout-2.4.0, hypothesis-6.152.1, xdist-3.8.0
12 workers [92 items]
..............................................................................FFF..FF..FFF.. [100%]
======================================================== FAILURES ========================================================
____________ TestDeprecatedGenericTimedelta.test_raise_warning_for_operation_with_generic_unit[add-5-value1] _____________
[gw5] linux -- Python 3.14.5 /home/warren/py3.14.5/bin/python3.14
self = <test_deprecations.TestDeprecatedGenericTimedelta object at 0x72f4985ee450>, value = np.timedelta64(10,'D')
generic_value = 5, op = <ufunc 'add'>
@pytest.mark.parametrize('value', [
np.timedelta64(3, "s"), np.timedelta64(10, "D")
])
@pytest.mark.parametrize('generic_value', [
5, 2
])
@pytest.mark.parametrize(
"op",
[
np.add,
np.subtract,
],
)
def test_raise_warning_for_operation_with_generic_unit(
self, value: int, generic_value: int, op: Callable
):
> self.assert_deprecated(op, num=1, args=(value, generic_value))
E AssertionError: 2 warnings found but 1 expected.
E {message : DeprecationWarning("The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. Please convert the integer with an explicit unit."), category : 'DeprecationWarning', filename : '/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/tests/test_deprecations.py', lineno : 83, line : None}
E {message : 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."), category : 'DeprecationWarning', filename : '/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/tests/test_deprecations.py', lineno : 83, line : None}
generic_value = 5
op = <ufunc 'add'>
self = <test_deprecations.TestDeprecatedGenericTimedelta object at 0x72f4985ee450>
value = np.timedelta64(10,'D')
numpy/_core/tests/test_deprecations.py:464: AssertionError
__________ TestDeprecatedGenericTimedelta.test_raise_warning_for_operation_with_generic_unit[subtract-5-value0] __________
[gw0] linux -- Python 3.14.5 /home/warren/py3.14.5/bin/python3.14
self = <test_deprecations.TestDeprecatedGenericTimedelta object at 0x70f36611e050>, value = np.timedelta64(3,'s')
generic_value = 5, op = <ufunc 'subtract'>
@pytest.mark.parametrize('value', [
np.timedelta64(3, "s"), np.timedelta64(10, "D")
])
@pytest.mark.parametrize('generic_value', [
5, 2
])
@pytest.mark.parametrize(
"op",
[
np.add,
np.subtract,
],
)
def test_raise_warning_for_operation_with_generic_unit(
self, value: int, generic_value: int, op: Callable
):
> self.assert_deprecated(op, num=1, args=(value, generic_value))
E AssertionError: 2 warnings found but 1 expected.
E {message : DeprecationWarning("The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. Please convert the integer with an explicit unit."), category : 'DeprecationWarning', filename : '/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/tests/test_deprecations.py', lineno : 83, line : None}
E {message : 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."), category : 'DeprecationWarning', filename : '/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/tests/test_deprecations.py', lineno : 83, line : None}
generic_value = 5
op = <ufunc 'subtract'>
self = <test_deprecations.TestDeprecatedGenericTimedelta object at 0x70f36611e050>
value = np.timedelta64(3,'s')
numpy/_core/tests/test_deprecations.py:464: AssertionError
__________ TestDeprecatedGenericTimedelta.test_raise_warning_for_operation_with_generic_unit[subtract-5-value1] __________
[gw11] linux -- Python 3.14.5 /home/warren/py3.14.5/bin/python3.14
self = <test_deprecations.TestDeprecatedGenericTimedelta object at 0x772e2550a250>, value = np.timedelta64(10,'D')
generic_value = 5, op = <ufunc 'subtract'>
@pytest.mark.parametrize('value', [
np.timedelta64(3, "s"), np.timedelta64(10, "D")
])
@pytest.mark.parametrize('generic_value', [
5, 2
])
@pytest.mark.parametrize(
"op",
[
np.add,
np.subtract,
],
)
def test_raise_warning_for_operation_with_generic_unit(
self, value: int, generic_value: int, op: Callable
):
> self.assert_deprecated(op, num=1, args=(value, generic_value))
E AssertionError: 2 warnings found but 1 expected.
E {message : DeprecationWarning("The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. Please convert the integer with an explicit unit."), category : 'DeprecationWarning', filename : '/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/tests/test_deprecations.py', lineno : 83, line : None}
E {message : 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."), category : 'DeprecationWarning', filename : '/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/tests/test_deprecations.py', lineno : 83, line : None}
generic_value = 5
op = <ufunc 'subtract'>
self = <test_deprecations.TestDeprecatedGenericTimedelta object at 0x772e2550a250>
value = np.timedelta64(10,'D')
numpy/_core/tests/test_deprecations.py:464: AssertionError
____________ TestDeprecatedGenericTimedelta.test_raise_warning_for_operation_with_generic_unit[add-2-value1] _____________
[gw8] linux -- Python 3.14.5 /home/warren/py3.14.5/bin/python3.14
self = <test_deprecations.TestDeprecatedGenericTimedelta object at 0x7e513aff7570>, value = np.timedelta64(10,'D')
generic_value = 2, op = <ufunc 'add'>
@pytest.mark.parametrize('value', [
np.timedelta64(3, "s"), np.timedelta64(10, "D")
])
@pytest.mark.parametrize('generic_value', [
5, 2
])
@pytest.mark.parametrize(
"op",
[
np.add,
np.subtract,
],
)
def test_raise_warning_for_operation_with_generic_unit(
self, value: int, generic_value: int, op: Callable
):
> self.assert_deprecated(op, num=1, args=(value, generic_value))
E AssertionError: 2 warnings found but 1 expected.
E {message : DeprecationWarning("The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. Please convert the integer with an explicit unit."), category : 'DeprecationWarning', filename : '/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/tests/test_deprecations.py', lineno : 83, line : None}
E {message : 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."), category : 'DeprecationWarning', filename : '/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/tests/test_deprecations.py', lineno : 83, line : None}
generic_value = 2
op = <ufunc 'add'>
self = <test_deprecations.TestDeprecatedGenericTimedelta object at 0x7e513aff7570>
value = np.timedelta64(10,'D')
numpy/_core/tests/test_deprecations.py:464: AssertionError
____________ TestDeprecatedGenericTimedelta.test_raise_warning_for_operation_with_generic_unit[add-5-value0] _____________
[gw9] linux -- Python 3.14.5 /home/warren/py3.14.5/bin/python3.14
self = <test_deprecations.TestDeprecatedGenericTimedelta object at 0x744ba45e96e0>, value = np.timedelta64(3,'s')
generic_value = 5, op = <ufunc 'add'>
@pytest.mark.parametrize('value', [
np.timedelta64(3, "s"), np.timedelta64(10, "D")
])
@pytest.mark.parametrize('generic_value', [
5, 2
])
@pytest.mark.parametrize(
"op",
[
np.add,
np.subtract,
],
)
def test_raise_warning_for_operation_with_generic_unit(
self, value: int, generic_value: int, op: Callable
):
> self.assert_deprecated(op, num=1, args=(value, generic_value))
E AssertionError: 2 warnings found but 1 expected.
E {message : DeprecationWarning("The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. Please convert the integer with an explicit unit."), category : 'DeprecationWarning', filename : '/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/tests/test_deprecations.py', lineno : 83, line : None}
E {message : 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."), category : 'DeprecationWarning', filename : '/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/tests/test_deprecations.py', lineno : 83, line : None}
generic_value = 5
op = <ufunc 'add'>
self = <test_deprecations.TestDeprecatedGenericTimedelta object at 0x744ba45e96e0>
value = np.timedelta64(3,'s')
numpy/_core/tests/test_deprecations.py:464: AssertionError
__________ TestDeprecatedGenericTimedelta.test_raise_warning_for_operation_with_generic_unit[subtract-2-value0] __________
[gw5] linux -- Python 3.14.5 /home/warren/py3.14.5/bin/python3.14
self = <test_deprecations.TestDeprecatedGenericTimedelta object at 0x72f4985dcd70>, value = np.timedelta64(3,'s')
generic_value = 2, op = <ufunc 'subtract'>
@pytest.mark.parametrize('value', [
np.timedelta64(3, "s"), np.timedelta64(10, "D")
])
@pytest.mark.parametrize('generic_value', [
5, 2
])
@pytest.mark.parametrize(
"op",
[
np.add,
np.subtract,
],
)
def test_raise_warning_for_operation_with_generic_unit(
self, value: int, generic_value: int, op: Callable
):
> self.assert_deprecated(op, num=1, args=(value, generic_value))
E AssertionError: 2 warnings found but 1 expected.
E {message : DeprecationWarning("The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. Please convert the integer with an explicit unit."), category : 'DeprecationWarning', filename : '/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/tests/test_deprecations.py', lineno : 83, line : None}
E {message : 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."), category : 'DeprecationWarning', filename : '/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/tests/test_deprecations.py', lineno : 83, line : None}
generic_value = 2
op = <ufunc 'subtract'>
self = <test_deprecations.TestDeprecatedGenericTimedelta object at 0x72f4985dcd70>
value = np.timedelta64(3,'s')
numpy/_core/tests/test_deprecations.py:464: AssertionError
____________ TestDeprecatedGenericTimedelta.test_raise_warning_for_operation_with_generic_unit[add-2-value0] _____________
[gw7] linux -- Python 3.14.5 /home/warren/py3.14.5/bin/python3.14
self = <test_deprecations.TestDeprecatedGenericTimedelta object at 0x728a36317130>, value = np.timedelta64(3,'s')
generic_value = 2, op = <ufunc 'add'>
@pytest.mark.parametrize('value', [
np.timedelta64(3, "s"), np.timedelta64(10, "D")
])
@pytest.mark.parametrize('generic_value', [
5, 2
])
@pytest.mark.parametrize(
"op",
[
np.add,
np.subtract,
],
)
def test_raise_warning_for_operation_with_generic_unit(
self, value: int, generic_value: int, op: Callable
):
> self.assert_deprecated(op, num=1, args=(value, generic_value))
E AssertionError: 2 warnings found but 1 expected.
E {message : DeprecationWarning("The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. Please convert the integer with an explicit unit."), category : 'DeprecationWarning', filename : '/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/tests/test_deprecations.py', lineno : 83, line : None}
E {message : 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."), category : 'DeprecationWarning', filename : '/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/tests/test_deprecations.py', lineno : 83, line : None}
generic_value = 2
op = <ufunc 'add'>
self = <test_deprecations.TestDeprecatedGenericTimedelta object at 0x728a36317130>
value = np.timedelta64(3,'s')
numpy/_core/tests/test_deprecations.py:464: AssertionError
__________ TestDeprecatedGenericTimedelta.test_raise_warning_for_operation_with_generic_unit[subtract-2-value1] __________
[gw10] linux -- Python 3.14.5 /home/warren/py3.14.5/bin/python3.14
self = <test_deprecations.TestDeprecatedGenericTimedelta object at 0x7cbafc1c8f50>, value = np.timedelta64(10,'D')
generic_value = 2, op = <ufunc 'subtract'>
@pytest.mark.parametrize('value', [
np.timedelta64(3, "s"), np.timedelta64(10, "D")
])
@pytest.mark.parametrize('generic_value', [
5, 2
])
@pytest.mark.parametrize(
"op",
[
np.add,
np.subtract,
],
)
def test_raise_warning_for_operation_with_generic_unit(
self, value: int, generic_value: int, op: Callable
):
> self.assert_deprecated(op, num=1, args=(value, generic_value))
E AssertionError: 2 warnings found but 1 expected.
E {message : DeprecationWarning("The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. Please convert the integer with an explicit unit."), category : 'DeprecationWarning', filename : '/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/tests/test_deprecations.py', lineno : 83, line : None}
E {message : 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."), category : 'DeprecationWarning', filename : '/home/warren/repos/git/forks/numpy/build-install/usr/lib/python3.14/site-packages/numpy/_core/tests/test_deprecations.py', lineno : 83, line : None}
generic_value = 2
op = <ufunc 'subtract'>
self = <test_deprecations.TestDeprecatedGenericTimedelta object at 0x7cbafc1c8f50>
value = np.timedelta64(10,'D')
numpy/_core/tests/test_deprecations.py:464: AssertionError
================================================ short test summary info =================================================
FAILED numpy/_core/tests/test_deprecations.py::TestDeprecatedGenericTimedelta::test_raise_warning_for_operation_with_generic_unit[add-5-value1] - AssertionError: 2 warnings found but 1 expected.
FAILED numpy/_core/tests/test_deprecations.py::TestDeprecatedGenericTimedelta::test_raise_warning_for_operation_with_generic_unit[subtract-5-value0] - AssertionError: 2 warnings found but 1 expected.
FAILED numpy/_core/tests/test_deprecations.py::TestDeprecatedGenericTimedelta::test_raise_warning_for_operation_with_generic_unit[subtract-5-value1] - AssertionError: 2 warnings found but 1 expected.
FAILED numpy/_core/tests/test_deprecations.py::TestDeprecatedGenericTimedelta::test_raise_warning_for_operation_with_generic_unit[add-2-value1] - AssertionError: 2 warnings found but 1 expected.
FAILED numpy/_core/tests/test_deprecations.py::TestDeprecatedGenericTimedelta::test_raise_warning_for_operation_with_generic_unit[add-5-value0] - AssertionError: 2 warnings found but 1 expected.
FAILED numpy/_core/tests/test_deprecations.py::TestDeprecatedGenericTimedelta::test_raise_warning_for_operation_with_generic_unit[subtract-2-value0] - AssertionError: 2 warnings found but 1 expected.
FAILED numpy/_core/tests/test_deprecations.py::TestDeprecatedGenericTimedelta::test_raise_warning_for_operation_with_generic_unit[add-2-value0] - AssertionError: 2 warnings found but 1 expected.
FAILED numpy/_core/tests/test_deprecations.py::TestDeprecatedGenericTimedelta::test_raise_warning_for_operation_with_generic_unit[subtract-2-value1] - AssertionError: 2 warnings found but 1 expected.
============================================== 8 failed, 84 passed in 1.26s ==============================================
Python and NumPy Versions
In [3]: import sys, numpy; print(numpy.__version__); print(sys.version)
2.6.0.dev0+git20260625.1d656e4
3.14.5 (main, May 19 2026, 11:40:22) [GCC 13.3.0]
Runtime Environment
In [5]: np.show_runtime()
[{'numpy_version': '2.6.0.dev0+git20260625.1d656e4',
'python': '3.14.5 (main, May 19 2026, 11:40:22) [GCC 13.3.0]',
'uname': uname_result(system='Linux', node='pop-os', release='7.0.11-76070011-generic', version='#202606011647~1780583645~24.04~5c4cc15 SMP PREEMPT_DYNAMIC Thu J', machine='x86_64')},
{'simd_extensions': {'baseline': ['X86_V2'],
'found': ['X86_V3'],
'not_found': ['X86_V4', 'AVX512_ICL', 'AVX512_SPR']}},
{'ignore_floating_point_errors_in_matmul': False},
{'architecture': 'Zen',
'filepath': '/usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so',
'internal_api': 'openblas',
'num_threads': 24,
'prefix': 'libopenblas',
'threading_layer': 'pthreads',
'user_api': 'blas',
'version': '0.3.26'}]
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]TST: deprecation test failure because an operation raises identical warnings, test expects one[/-][+]TST: deprecation test failure because an operation raises two warnings, test expects one[/+]ngoldbaum commentedon Jun 25, 2026
I have #31617 open to fix this. The fix is kind of involved though.