Arrayutils
Utility functions for processing arrays.
PeriodicProcessSample
Bases: NamedTuple
A container for holding the output from process.PeriodicProcess().
Attributes:
| Name | Type | Description |
|---|---|---|
value |
ArrayLike
|
The sampled quantity. |
repeat_until_n
Repeat each entry in data a given number of times (period_size)
until an array of length n_timepoints has been produced.
Notes
Using the offset parameter, the function will offset the data after
the repeat operation. So, if the offset is 2, the repeat operation
will repeat the data until n_timepoints + 2 and then offset the
data by 2, returning an array of size n_timepoints. This is a way to start
part-way into a period. For example, the following code will each array
element four times until 10 timepoints and then offset the data by 2:
.. code-block:: python data = jnp.array([1, 2, 3]) repeat_until_n(data, 4, 10, 2) # Array([1, 1, 2, 2, 2, 2, 3, 3, 3, 3], dtype=int32)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ArrayLike
|
Data to broadcast. |
required |
period_size
|
int
|
Size of the period for the repeat broadcast. |
required |
n_timepoints
|
int
|
Duration of the sequence. |
required |
offset
|
int
|
Relative point at which data starts, must be between 0 and period_size - 1. By default 0, i.e., no offset. |
0
|
Returns:
| Type | Description |
|---|---|
ArrayLike
|
Repeated data. |
Source code in pyrenew/arrayutils.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
tile_until_n
Tile the data until it reaches n_timepoints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ArrayLike
|
Data to broadcast. |
required |
n_timepoints
|
int
|
Duration of the sequence. |
required |
offset
|
int
|
Relative point at which data starts, must be a non-negative integer. Default is zero, i.e., no offset. |
0
|
Notes
Using the offset parameter, the function will start the broadcast
from the offset-th element of the data. If the data is shorter than
n_timepoints, the function will tile the data until it
reaches n_timepoints.
Returns:
| Type | Description |
|---|---|
ArrayLike
|
Tiled data. |
Source code in pyrenew/arrayutils.py
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 | |