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

feihoo87 / waveforms / 7222551172

15 Dec 2023 01:16PM UTC coverage: 33.393% (-0.07%) from 33.465%
7222551172

push

github

feihoo87
fix wave_sum

1 of 1 new or added line in 1 file covered. (100.0%)

233 existing lines in 2 files now uncovered.

2795 of 8370 relevant lines covered (33.39%)

2.99 hits per line

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

0.0
/waveforms/utils.py
1
import inspect
×
UNCOV
2
from concurrent.futures import Future
×
3
from types import MappingProxyType
×
4

UNCOV
5
import numpy as np
×
UNCOV
6
import scipy.sparse as sp
×
7

8

UNCOV
9
def call_func_with_kwds(func, args, kwds, log=None):
×
10
    funcname = getattr(func, '__name__', repr(func))
×
11
    sig = inspect.signature(func)
×
12
    for p in sig.parameters.values():
×
13
        if p.kind == p.VAR_KEYWORD:
×
14
            return func(*args, **kwds)
×
15
    kw = {
×
16
        k: v
17
        for k, v in kwds.items()
18
        if k in list(sig.parameters.keys())[len(args):]
19
    }
20
    try:
×
21
        args = [
×
22
            arg.result() if isinstance(arg, Future) else arg for arg in args
23
        ]
24
        kw = {
×
25
            k: v.result() if isinstance(v, Future) else v
26
            for k, v in kw.items()
27
        }
28
        return func(*args, **kw)
×
29
    except:
×
30
        if log:
×
UNCOV
31
            log.exception(f'Call {funcname} with {args} and {kw}')
×
UNCOV
32
        raise
×
33
    finally:
UNCOV
34
        if log:
×
UNCOV
35
            log.debug(f'Call {funcname} with {args} and {kw}')
×
36

37

UNCOV
38
def try_to_call(x, args, kwds, log=None):
×
UNCOV
39
    if callable(x):
×
UNCOV
40
        return call_func_with_kwds(x, args, kwds, log)
×
UNCOV
41
    return x
×
42

43

UNCOV
44
def freeze(x):
×
45
    """Freeze a mutable object.
46
    """
UNCOV
47
    if isinstance(x, (int, float, complex, str, bytes, type(None))):
×
UNCOV
48
        pass
×
UNCOV
49
    elif isinstance(x, (list, tuple)):
×
UNCOV
50
        return tuple([freeze(y) for y in x])
×
UNCOV
51
    elif isinstance(x, dict):
×
UNCOV
52
        return MappingProxyType({k: freeze(v) for k, v in x.items()})
×
UNCOV
53
    elif isinstance(x, set):
×
UNCOV
54
        return frozenset([freeze(y) for y in x])
×
UNCOV
55
    elif isinstance(x, (np.ndarray, np.matrix)):
×
UNCOV
56
        x.flags.writeable = False
×
UNCOV
57
    elif isinstance(x, sp.spmatrix):
×
UNCOV
58
        x.data.flags.writeable = False
×
UNCOV
59
        if x.format in {'csr', 'csc', 'bsr'}:
×
UNCOV
60
            x.indices.flags.writeable = False
×
UNCOV
61
            x.indptr.flags.writeable = False
×
UNCOV
62
        elif x.format == 'coo':
×
UNCOV
63
            x.row.flags.writeable = False
×
UNCOV
64
            x.col.flags.writeable = False
×
UNCOV
65
    elif isinstance(x, bytearray):
×
UNCOV
66
        x = bytes(x)
×
UNCOV
67
    return x
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc