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

QuantEcon / QuantEcon.py / 30591856746

30 Jul 2026 11:52PM UTC coverage: 90.546% (-3.2%) from 93.725%
30591856746

Pull #908

github

web-flow
Merge fe807703b into 0c5b97a19
Pull Request #908: FIX: assert the sparse-Q equality check in test_ddp.py

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