• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

QuantEcon / QuantEcon.py / 30519033396

30 Jul 2026 06:15AM UTC coverage: 90.546% (-3.2%) from 93.725%
30519033396

push

github

web-flow
CI: Measure Numba JIT coverage in a single dedicated job (#913)

Remove the five Numba decorator patterns (@jit, @njit, @overload,
@guvectorize) from .coveragerc exclude_lines. coverage.py excludes the
entire decorated function when a decorator line matches, so ~1,700
statements of jitted code were invisible to coverage. Also omit the
test tree (*/tests/*) so the headline figure measures library code
only.

Since numba 0.61 (fixed to respect coverage configuration in 0.62), the
compiler emits coverage for JIT functions at compile time when
NUMBA_JIT_COVERAGE=1. Because emission happens during lowering, functions
with cache=True loaded from a warm on-disk cache report nothing, so the
coverage job points NUMBA_CACHE_DIR at a throwaway directory to force
compilation.

Restructure ci.yml accordingly:

- The OS x Python matrix now runs plain pytest (the production
  configuration, no coverage overhead).
- A new single `coverage` job (ubuntu, Python 3.13) runs the suite once
  with NUMBA_JIT_COVERAGE=1 and uploads to Coveralls. With one producer,
  the old per-matrix Coveralls gate is obsolete.
- Pin numba>=0.62 in environment.yml; without the env var taking effect
  the reported total would silently drop by ~5 pp.

New baseline: 90.55% (5,638 source statements, 533 missed), 600 tests
passing.

Closes #871

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

5105 of 5638 relevant lines covered (90.55%)

0.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.86
/quantecon/util/array.py
1
"""
2
Array Utilities
3
===============
4

5
Array
6
-----
7
searchsorted
8

9
"""
10

11
import warnings
1✔
12
from numba import jit, objmode
1✔
13

14
# ----------------- #
15
# -ARRAY UTILITIES- #
16
# ----------------- #
17

18
@jit(nopython=True)
1✔
19
def searchsorted(a, v):
1✔
20
    """
21
    Custom version of np.searchsorted. Return the largest index `i` such
22
    that `a[i-1] <= v < a[i]` (for `i = 0`, `v < a[0]`); if `v[n-1] <=
23
    v`, return `n`, where `n = len(a)`.
24

25
    .. deprecated::
26

27
        Deprecated, use `np.searchsorted(a, v, side='right')` instead.
28

29
    Parameters
30
    ----------
31
    a : ndarray(float, ndim=1)
32
        Input array. Must be sorted in ascending order.
33

34
    v : scalar(float)
35
        Value to be compared with elements of `a`.
36

37
    Returns
38
    -------
39
    scalar(int)
40
        Largest index `i` such that `a[i-1] <= v < a[i]`, or len(a) if
41
        no such index exists.
42

43
    Notes
44
    -----
45
    This routine is jit-complied if the module Numba is vailable; if
46
    not, it is an alias of np.searchsorted(a, v, side='right').
47

48
    Examples
49
    --------
50
    >>> a = np.array([0.2, 0.4, 1.0])
51
    >>> searchsorted(a, 0.1)
52
    0
53
    >>> searchsorted(a, 0.4)
54
    2
55
    >>> searchsorted(a, 2)
56
    3
57

58
    """
59
    with objmode():
1✔
60
        warnings.warn(
×
61
            "`searchsorted(a, v)` is deprecated. "
62
            "Use `np.searchsorted(a, v, side='right')` instead.",
63
            DeprecationWarning,
64
            stacklevel=2,
65
        )
66

67
    lo = -1
1✔
68
    hi = len(a)
1✔
69
    while(lo < hi-1):
1✔
70
        m = (lo + hi) // 2
1✔
71
        if v < a[m]:
1✔
72
            hi = m
1✔
73
        else:
74
            lo = m
1✔
75
    return hi
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc