/
tests.txt
76 lines (57 loc) · 1.85 KB
/
tests.txt
1
2
3
4
5
6
7
8
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
.. testsetup::
>>> decimals = 8
>>> import numpy as np
>>> np.set_printoptions(precision=decimals)
>>> builtin_round = round
>>> # Don't use np.round; it's stupid.
>>> def round(value):
... try:
... return [round(v) for v in value]
... except TypeError:
... return builtin_round(value, decimals)
# TODO: Organize these tests better.
# Move examples that aren't useful for users into this folder.
# TODO: Test the inherited methods in SimResList and LinResList.
>>> from modelicares import SimRes
>>> sim = SimRes('examples/ChuaCircuit.mat')
>>> sim['L.v'].array(t=(0, 10)) # doctest: +NORMALIZE_WHITESPACE
array([[ 0. , 0. ],
[ 5. , 0.10923497],
[ 10. , 0.21083504]], dtype=float32)
>>> sim['L.v'].description
u'Voltage drop between the two pins (= p.v - n.v)'
>>> sim['G.T_heatPort'].displayUnit
'degC'
>>> round(sim['Ro.R'].value())
0.0125
>>> sim['L.v'].value() # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
Traceback (most recent call last):
...
ValueError: The variable is not a constant. Use values() instead of value().
>>> round(sim(['C1.v', 'L.v']).FV())
[2.42098355, -0.25352862]
>>> round(sim['C1.v'].IV())
4.0
>>> round(sim['L.v'].mean())
0.01473382
>>> round(sim['L.v'].max())
0.77344114
>>> round(sim['L.v'].min())
-0.9450165
>>> sim['L.v'].times(t=(0, 20))
array([ 0., 5., 10., 15., 20.], dtype=float32)
>>> sim['L.v'].unit
'V'
>>> sim['L.v'].values(t=(0, 20)) # doctest: +NORMALIZE_WHITESPACE
array([ 0. , 0.10923497, 0.21083504, 0.30462351, 0.39040083], dtype=float32)
>>> sim['L.vv'].values() # doctest: +ELLIPSIS
Traceback (most recent call last):
...
LookupError: L.vv is not a valid variable name.
<BLANKLINE>
Did you mean one of these?
L.v
L.p.v
L.n.v
>>> round(sim['L.v'].values(t=[0, 2000]))
[0.0, 0.15459341]