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

SDXorg / pysd / 8504590410

29 Feb 2024 10:05AM CUT coverage: 99.879%. Remained the same
8504590410

push

github

enekomartinmartinez
Fix initialization dependencies for Smooth

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

4965 of 4971 relevant lines covered (99.88%)

1.0 hits per line

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

100.0
/pysd/builders/python/python_functions.py
1

2
# functions that can be diretcly applied over an array
3
functionspace = {
1✔
4
    # directly build functions without dependencies
5
    "elmcount": ("len(%(0)s)", None),
6

7
    # directly build numpy based functions
8
    "pi": ("np.pi", ("numpy",)),
9
    "abs": ("np.abs(%(0)s)", ("numpy",)),
10
    "power": ("np.power(%(0)s,%(1)s)", ("numpy",)),
11
    "min": ("np.minimum(%(0)s, %(1)s)", ("numpy",)),
12
    "max": ("np.maximum(%(0)s, %(1)s)", ("numpy",)),
13
    "exp": ("np.exp(%(0)s)", ("numpy",)),
14
    "sin": ("np.sin(%(0)s)", ("numpy",)),
15
    "cos": ("np.cos(%(0)s)", ("numpy",)),
16
    "tan": ("np.tan(%(0)s)", ("numpy",)),
17
    "arcsin": ("np.arcsin(%(0)s)", ("numpy",)),
18
    "arccos": ("np.arccos(%(0)s)", ("numpy",)),
19
    "arctan": ("np.arctan(%(0)s)", ("numpy",)),
20
    "sinh": ("np.sinh(%(0)s)", ("numpy",)),
21
    "cosh": ("np.cosh(%(0)s)", ("numpy",)),
22
    "tanh": ("np.tanh(%(0)s)", ("numpy",)),
23
    "sqrt": ("np.sqrt(%(0)s)", ("numpy",)),
24
    "ln": ("np.log(%(0)s)", ("numpy",)),
25
    "log": ("(np.log(%(0)s)/np.log(%(1)s))", ("numpy",)),
26
    # NUMPY: "invert_matrix": ("np.linalg.inv(%(0)s)", ("numpy",)),
27

28
    # vector functions with axis to apply over
29
    # NUMPY:
30
    # "prod": "np.prod(%(0)s, axis=%(axis)s)", ("numpy",)),
31
    # "sum": "np.sum(%(0)s, axis=%(axis)s)", ("numpy",)),
32
    # "vmax": "np.max(%(0)s, axis=%(axis)s)", ("numpy", )),
33
    # "vmin": "np.min(%(0)s, axis=%(axis)s)", ("numpy",))
34
    "prod": ("prod(%(0)s, dim=%(axis)s)", ("functions", "prod")),
35
    "sum": ("sum(%(0)s, dim=%(axis)s)", ("functions", "sum")),
36
    "vmax": ("vmax(%(0)s, dim=%(axis)s)", ("functions", "vmax")),
37
    "vmin": ("vmin(%(0)s, dim=%(axis)s)", ("functions", "vmin")),
38
    "vmax_xmile": ("vmax(%(0)s)", ("functions", "vmax")),
39
    "vmin_xmile": ("vmin(%(0)s)", ("functions", "vmin")),
40
    "vector_select": (
41
        "vector_select(%(0)s, %(1)s, %(axis)s, %(2)s, %(3)s, %(4)s)",
42
        ("functions", "vector_select")
43
    ),
44

45
    # functions defined in pysd.py_bakcend.functions
46
    "active_initial": (
47
        "active_initial(__data[\"time\"].stage, lambda: %(0)s, %(1)s)",
48
        ("functions", "active_initial")),
49
    "if_then_else": (
50
        "if_then_else(%(0)s, lambda: %(1)s, lambda: %(2)s)",
51
        ("functions", "if_then_else")),
52
    "integer": (
53
        "integer(%(0)s)",
54
        ("functions", "integer")),
55
    "invert_matrix": (  # NUMPY: remove
56
        "invert_matrix(%(0)s)",
57
        ("functions", "invert_matrix")),  # NUMPY: remove
58
    "modulo": (
59
        "modulo(%(0)s, %(1)s)",
60
        ("functions", "modulo")),
61
    "pulse": (
62
        "pulse(__data['time'], %(0)s, width=%(1)s)",
63
        ("functions", "pulse")),
64
    "Xpulse": (
65
        "pulse(__data['time'], %(0)s, magnitude=%(1)s)",
66
        ("functions", "pulse")),
67
    "pulse_train": (
68
        "pulse(__data['time'], %(0)s, repeat_time=%(1)s, width=%(2)s, "\
69
        "end=%(3)s)",
70
        ("functions", "pulse")),
71
    "Xpulse_train": (
72
        "pulse(__data['time'], %(0)s, repeat_time=%(1)s, magnitude=%(2)s)",
73
        ("functions", "pulse")),
74
    "get_time_value": (
75
        "get_time_value(__data['time'], %(0)s, %(1)s, %(2)s)",
76
        ("functions", "get_time_value")),
77
    "quantum": (
78
        "quantum(%(0)s, %(1)s)",
79
        ("functions", "quantum")),
80
    "Xramp": (
81
        "ramp(__data['time'], %(0)s, %(1)s)",
82
        ("functions", "ramp")),
83
    "ramp": (
84
        "ramp(__data['time'], %(0)s, %(1)s, %(2)s)",
85
        ("functions", "ramp")),
86
    "step": (
87
        "step(__data['time'], %(0)s, %(1)s)",
88
        ("functions", "step")),
89
    "xidz": (
90
        "xidz(%(0)s, %(1)s, %(2)s)",
91
        ("functions", "xidz")),
92
    "zidz": (
93
        "zidz(%(0)s, %(1)s)",
94
        ("functions", "zidz")),
95
    "vector_sort_order": (
96
        "vector_sort_order(%(0)s, %(1)s)",
97
        ("functions", "vector_sort_order")),
98
    "vector_reorder": (
99
        "vector_reorder(%(0)s, %(1)s)",
100
        ("functions", "vector_reorder")),
101
    "vector_rank": (
102
        "vector_rank(%(0)s, %(1)s)",
103
        ("functions", "vector_rank")),
104

105
    # random functions must have the shape of the component subscripts
106
    # most of them are shifted, scaled and truncated
107
    # TODO: it is difficult to find same parametrization in Python,
108
    # maybe build a new model
109
    "random_0_1": (
110
        "np.random.uniform(0, 1, size=%(size)s)",
111
        ("numpy",)),
112
    "random_uniform": (
113
        "np.random.uniform(%(0)s, %(1)s, size=%(size)s)",
114
        ("numpy",)),
115
    "random_normal": (
116
        "stats.truncnorm.rvs(%(0)s, %(1)s, loc=%(2)s, scale=%(3)s,"
117
        " size=%(size)s)",
118
        ("scipy", "stats")),
119
}
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

© 2025 Coveralls, Inc