|
15 | 15 | cn = 0
|
16 | 16 |
|
17 | 17 |
|
18 |
| -def itdict(d, size): |
| 18 | +def itdict(dt, size): |
19 | 19 | global cn
|
20 |
| - while cn < len(d): |
21 |
| - for k, v in d.items(): |
| 20 | + while cn < len(dt): |
| 21 | + for k, v in dt.items(): |
22 | 22 | if len(v) == 3:
|
23 | 23 | dist, low, high = v
|
24 | 24 | if "tbi" in str(low):
|
25 |
| - if type(d[low]) is int: |
26 |
| - d[k][1] = d[low] |
| 25 | + if len(dt[low]) == size: |
| 26 | + dt[k][1] = dt[low] |
27 | 27 | elif "tbi" in str(high):
|
28 |
| - if type(d[high]) is int: |
29 |
| - d[k][2] = d[high] |
| 28 | + if len(dt[high]) == size: |
| 29 | + dt[k][2] = dt[high] |
30 | 30 | else:
|
31 | 31 | draw = getattr(DrawDist(), dist[1:])
|
32 |
| - assert dist[1:] in avail_dist,"dist not recognized" |
33 |
| - d[k] = draw(float(low), float(high), size) |
| 32 | + assert dist[1:] in avail_dist, "dist not recognized" |
| 33 | + if type(low) is str and type(high) is str: |
| 34 | + # low is str, high is str '0' '123' |
| 35 | + dt[k] = draw(float(low), float(high), size) |
| 36 | + elif type(low) is str and len(high) == size: |
| 37 | + # low is str, high is array '0' ([1,2,3]) |
| 38 | + dt[k] = draw([float(low)]*size, high, size) |
| 39 | + elif len(low) == size and type(high) is str: |
| 40 | + # low is array, high is str ([1,2,3]) '10' |
| 41 | + dt[k] = draw(low, [float(high)]*size, size) |
| 42 | + elif len(low) == size and len(high) == size: |
| 43 | + # low is array, high is array ([1,2,3]) ([1,2,3]) |
| 44 | + dt[k] = draw(low, high, size) |
34 | 45 | cn += 1
|
35 |
| - return itdict(d, size) |
36 |
| - return d |
| 46 | + return itdict(dt, size) |
| 47 | + return dt |
37 | 48 |
|
38 | 49 | # d={"tbi1": [0, "tbi2"], "tbi2": ["tbi3", "tbi4"], "tbi3":[100, "tbi4"],"tbi4": [1000, 10000]}
|
0 commit comments