question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

numba 0.55 breaks compatibility with coverage

See original GitHub issue

Reporting a bug

  • I have tried using the latest released version of Numba (most recent is visible in the change log (https://github.com/numba/numba/blob/master/CHANGE_LOG).
  • I have included a self contained code sample to reproduce the problem. i.e. it’s possible to run as ‘python bug.py’.

Since numba 0.55 python files importing numba are causing trouble in combination with coverage xml.

Example

“example.py”:

from numba import jit
import numpy as np


@jit(nopython=True) # Set "nopython" mode for best performance, equivalent to @njit
def go_fast(a):
    trace = 0.0
    for i in range(a.shape[0]):
        trace += np.tanh(a[i, i])
    return a + trace

def main():
    x = np.arange(100).reshape(10, 10)
    print(go_fast(x))


if __name__ == '__main__':
    main()

Expected behavior (as with numba 0.54)

$ python -m coverage run example.py
[[  9.  10.  11.  12.  13.  14.  15.  16.  17.  18.]
 [ 19.  20.  21.  22.  23.  24.  25.  26.  27.  28.]
 [ 29.  30.  31.  32.  33.  34.  35.  36.  37.  38.]
 [ 39.  40.  41.  42.  43.  44.  45.  46.  47.  48.]
 [ 49.  50.  51.  52.  53.  54.  55.  56.  57.  58.]
 [ 59.  60.  61.  62.  63.  64.  65.  66.  67.  68.]
 [ 69.  70.  71.  72.  73.  74.  75.  76.  77.  78.]
 [ 79.  80.  81.  82.  83.  84.  85.  86.  87.  88.]
 [ 89.  90.  91.  92.  93.  94.  95.  96.  97.  98.]
 [ 99. 100. 101. 102. 103. 104. 105. 106. 107. 108.]]
$ python -m coverage xml
Wrote XML report to coverage.xml

Found

$ python -m coverage run example.py
[[  9.  10.  11.  12.  13.  14.  15.  16.  17.  18.]
 [ 19.  20.  21.  22.  23.  24.  25.  26.  27.  28.]
 [ 29.  30.  31.  32.  33.  34.  35.  36.  37.  38.]
 [ 39.  40.  41.  42.  43.  44.  45.  46.  47.  48.]
 [ 49.  50.  51.  52.  53.  54.  55.  56.  57.  58.]
 [ 59.  60.  61.  62.  63.  64.  65.  66.  67.  68.]
 [ 69.  70.  71.  72.  73.  74.  75.  76.  77.  78.]
 [ 79.  80.  81.  82.  83.  84.  85.  86.  87.  88.]
 [ 89.  90.  91.  92.  93.  94.  95.  96.  97.  98.]
 [ 99. 100. 101. 102. 103. 104. 105. 106. 107. 108.]]
$ python -m coverage xml
No source for code: '/path/to/working/directory/__numba_array_expr_synthetic_module_example.py'.

coverage version is 6.2.

Many thanks for looking into this.
Best, Emanuel

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
emanuel-schmidcommented, Jan 18, 2022

Sure, fully aware of that. It’s the effort that’s valued. 😃

1reaction
gmarkallcommented, Jan 17, 2022

Applying:

diff --git a/numba/np/ufunc/array_exprs.py b/numba/np/ufunc/array_exprs.py
index 3fe85ba5e..bb8815ddc 100644
--- a/numba/np/ufunc/array_exprs.py
+++ b/numba/np/ufunc/array_exprs.py
@@ -333,7 +333,7 @@ def _lower_array_expr(lowerer, expr):
     '''Lower an array expression built by RewriteArrayExprs.
     '''
     expr_name = "__numba_array_expr_%s" % (hex(hash(expr)).replace("-", "_"))
-    expr_filename = f"__numba_array_expr_synthetic_module_{expr.loc.filename}"
+    expr_filename = expr.loc.filename
     expr_var_list = expr.list_vars()
     # The expression may use a given variable several times, but we
     # should only create one parameter for it.

appears to resolve this issue, and doesn’t introduce any failures in any of the tests added or modified in #7177.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Release Notes — Numba 0.56.4+0.g288a38bbd.dirty-py3.7 ...
A backwards compatibility “shim” is provided for this release so as to not immediately break projects using Numba's internals. If a module is...
Read more >
Call to cuLinkAddData results in UNKNOWN_CUDA_ERROR
Hi there, I am using numba without conda in Manjaro OS. That is, just using the nvidia driver and nvidia toolkit system installations....
Read more >
Installation — Numba 0.50.1 documentation
Compatibility. Numba is compatible with Python 3.6 or later, and Numpy versions 1.15 or later. Our supported platforms are: Linux x86 (32-bit and...
Read more >
Troubleshooting and tips — Numba 0.50.1 documentation
There can be various reasons why Numba cannot compile your code, and raises an error instead. One common reason is that your code...
Read more >
A guide to using @overload — Numba 0.50.1 documentation
Numba supports NumPy through the provision of @jit compatible ... to look at that are well implemented in terms of accepted types and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found