Skip to content

Instantly share code, notes, and snippets.

@esc
Last active June 17, 2025 10:10
Show Gist options
  • Save esc/7df1fcc84ac62f4c6c8052f5460f4e1f to your computer and use it in GitHub Desktop.
Save esc/7df1fcc84ac62f4c6c8052f5460f4e1f to your computer and use it in GitHub Desktop.

As above.

LOG 2025-06-17

I present the following two sessions.

Using the PR at: numba/numba#9862

 💣 zsh» make numba_cov_active
NUMBA_JIT_COVERAGE=1 pytest --cov=issue_9859  test_issue_9859.py
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.13.1, pytest-8.3.4, pluggy-1.5.0
rootdir: /Users/esc/numba-issue9859
plugins: cov-6.0.0
collected 2 items

test_issue_9859.py ..                                                                                                                                                                                [100%]

============================================================================================= warnings summary =============================================================================================
../git/numba/numba/core/ir_utils.py:2206
  /Users/esc/git/numba/numba/core/ir_utils.py:2206: NumbaPendingDeprecationWarning:
  Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'l' of function 'fun'.

  For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

  File "issue_9859.py", line 6:
  @njit
  def fun(l):
  ^

    warnings.warn(NumbaPendingDeprecationWarning(msg, loc=loc))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

---------- coverage: platform darwin, python 3.13.1-final-0 ----------
Name            Stmts   Miss  Cover
-----------------------------------
issue_9859.py       5      0   100%
-----------------------------------
TOTAL               5      0   100%

======================================================================================= 2 passed, 1 warning in 2.96s =======================================================================================
esc@cyberdeck [numba_3.13] [numba-issue9859:main:★] ~/numba-issue9859
 💣 zsh» make numba_cov_disable
NUMBA_JIT_COVERAGE=0 pytest --cov=issue_9859  test_issue_9859.py
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.13.1, pytest-8.3.4, pluggy-1.5.0
rootdir: /Users/esc/numba-issue9859
plugins: cov-6.0.0
collected 2 items

test_issue_9859.py ..                                                                                                                                                                                [100%]

============================================================================================= warnings summary =============================================================================================
../git/numba/numba/core/ir_utils.py:2206
  /Users/esc/git/numba/numba/core/ir_utils.py:2206: NumbaPendingDeprecationWarning:
  Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'l' of function 'fun'.

  For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

  File "issue_9859.py", line 6:
  @njit
  def fun(l):
  ^

    warnings.warn(NumbaPendingDeprecationWarning(msg, loc=loc))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

---------- coverage: platform darwin, python 3.13.1-final-0 ----------
Name            Stmts   Miss  Cover
-----------------------------------
issue_9859.py       5      0   100%
-----------------------------------
TOTAL               5      0   100%

======================================================================================= 2 passed, 1 warning in 0.95s =======================================================================================

With main at: eb6b9790a803e54c0285f5328a5234aab8c830f4

 💣 zsh» make numba_cov_active
NUMBA_JIT_COVERAGE=1 pytest --cov=issue_9859  test_issue_9859.py
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.13.1, pytest-8.3.4, pluggy-1.5.0
rootdir: /Users/esc/numba-issue9859
plugins: cov-6.0.0
collected 2 items

test_issue_9859.py ..                                                                                                                                                                                [100%]

============================================================================================= warnings summary =============================================================================================
../git/numba/numba/core/ir_utils.py:2206
  /Users/esc/git/numba/numba/core/ir_utils.py:2206: NumbaPendingDeprecationWarning:
  Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'l' of function 'fun'.

  For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

  File "issue_9859.py", line 6:
  @njit
  def fun(l):
  ^

    warnings.warn(NumbaPendingDeprecationWarning(msg, loc=loc))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

---------- coverage: platform darwin, python 3.13.1-final-0 ----------
Name            Stmts   Miss  Cover
-----------------------------------
issue_9859.py       5      1    80%
-----------------------------------
TOTAL               5      1    80%

======================================================================================= 2 passed, 1 warning in 3.11s =======================================================================================
Exception ignored in atexit callback <function _get_coverage_data.<locals>._finalize at 0x113a636a0>:
Traceback (most recent call last):
  File "/Users/esc/git/numba/numba/misc/coverage_support.py", line 61, in _finalize
    cov.get_data().update(covdata)
  File "/Users/esc/miniconda3-arm64/envs/numba_3.13/lib/python3.13/site-packages/coverage/sqldata.py", line 666, in update
    raise DataError("Can't combine branch coverage data with statement data")
coverage.exceptions.DataError: Can't combine branch coverage data with statement data
esc@cyberdeck [numba_3.13] [numba-issue9859:main:★] ~/numba-issue9859
 💣 zsh» make numba_cov_disable
NUMBA_JIT_COVERAGE=0 pytest --cov=issue_9859  test_issue_9859.py
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.13.1, pytest-8.3.4, pluggy-1.5.0
rootdir: /Users/esc/numba-issue9859
plugins: cov-6.0.0
collected 2 items

test_issue_9859.py ..                                                                                                                                                                                [100%]

============================================================================================= warnings summary =============================================================================================
../git/numba/numba/core/ir_utils.py:2206
  /Users/esc/git/numba/numba/core/ir_utils.py:2206: NumbaPendingDeprecationWarning:
  Encountered the use of a type that is scheduled for deprecation: type 'reflected list' found for argument 'l' of function 'fun'.

  For more information visit https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-reflection-for-list-and-set-types

  File "issue_9859.py", line 6:
  @njit
  def fun(l):
  ^

    warnings.warn(NumbaPendingDeprecationWarning(msg, loc=loc))

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

---------- coverage: platform darwin, python 3.13.1-final-0 ----------
Name            Stmts   Miss  Cover
-----------------------------------
issue_9859.py       5      1    80%
-----------------------------------
TOTAL               5      1    80%

======================================================================================= 2 passed, 1 warning in 1.00s =======================================================================================

Conclusion: There are differences in how the patch provided influences the execution of this test code. However I have not been able to reproduce the original issue at:

numba/numba#9859

The differences are:

Using the PR coverage is 100% in both cases. Using main, coverage is always only 80% and in the case of NUMBA_JIT_COVERAGE=1 I see an exception after execution:

Exception ignored in atexit callback <function _get_coverage_data.<locals>._finalize at 0x113a636a0>:
Traceback (most recent call last):
  File "/Users/esc/git/numba/numba/misc/coverage_support.py", line 61, in _finalize
    cov.get_data().update(covdata)
  File "/Users/esc/miniconda3-arm64/envs/numba_3.13/lib/python3.13/site-packages/coverage/sqldata.py", line 666, in update
    raise DataError("Can't combine branch coverage data with statement data")
coverage.exceptions.DataError: Can't combine branch coverage data with statement data

Taking a closer look at:

https://github.com/nedbat/coveragepy/blob/master/coverage/sqldata.py#L666

.. it seems that there are two data sets that can not be combined.

Then taking a closer look at:

https://github.com/numba/numba/blob/main/numba/misc/coverage_support.py

.. it looks like there is one set of coverage data produced from regular cpython execution and another set produced by Numba during JIT execution are being combined:

https://github.com/numba/numba/blob/main/numba/misc/coverage_support.py#L61

.. so the conclusion is, that the coverage data produced by Numba is corrupt or incompatible. This makes sense. The original issue here was that the coverage data being produced by Numba for JIT compiled execution is at least bogus. In the reported case it is interpreted as coming from within the compiler. Thus, it also makes sense that the PR fixes this and that the coverage goes up to 100% -- the one line from the JIT compiled function is also included. Overall this is good evidence that the PR does address some kind of issue.

from numba import njit
from numba.typed import List
@njit
def fun(l):
l.append(2)
numba_cov_active:
NUMBA_JIT_COVERAGE=1 pytest --cov=issue_9859 test_issue_9859.py
numba_cov_disable:
NUMBA_JIT_COVERAGE=0 pytest --cov=issue_9859 test_issue_9859.py
from numba.typed import List
from issue_9859 import fun
# Warmup
mylist = List([1])
fun(mylist)
mylist = [1]
fun(mylist)
def test_fun_typed():
mylist = List([1])
fun(mylist)
assert list(mylist) == [1, 2]
def test_fun_reflected():
mylist = [1]
fun(mylist)
assert list(mylist) == [1, 2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment