Reference
Utilities¶
Output grid¶
The single shared builder of the uniform, endpoint-inclusive output time grid
([t0, t0+dt, …, tf]) that every integrator samples its results onto.
make_output_grid
¶
Build a uniform output grid from t0 to tf (inclusive).
The grid is arange(t0, tf, dt) with tf appended when the last
sample would otherwise fall short of it — so the final time is always
sampled exactly, regardless of whether dt divides tf - t0.
The endpoint tolerance
A last interior sample within four ULPs of tf is replaced by the exact
endpoint, avoiding a duplicate roundoff-sized tail. The slack is capped at
a small fraction of dt and never replaces the start sample: short time
units are valid, and even a sub-picosecond window must retain both bounds.
Building offsets from zero avoids accumulating the rounded t0 + dt
increment when the start time is large compared with the sampling interval.
This is the one chokepoint every flow family (ODE / DDE / SDE) and the
engine run layer build their grid through, so it is also where the
silent-footgun horizons are caught early with a domain message: a
non-positive dt (which used to surface as a bare ZeroDivisionError
from this helper) and a window that does not run forward in time (which used
to yield a one-sample garbage trajectory).
Every bound must additionally be finite. dt and final_time were
guarded only by > 0 / > t0, which +inf satisfies: an infinite
dt slipped through to a two-sample [t0, tf] grid (a "trajectory" of
one giant step, silently nothing like the requested sampling), and an
infinite final_time reached :func:numpy.arange, which raised the
unhelpful ValueError: Maximum allowed size exceeded. Both are rejected
here instead, naming the offending value.
| PARAMETER | DESCRIPTION |
|---|---|
t0
|
Start and end of the window.
TYPE:
|
tf
|
Start and end of the window.
TYPE:
|
dt
|
Output sampling interval. Must be strictly positive.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ndarray
|
The output times, with |
| RAISES | DESCRIPTION |
|---|---|
InvalidParameterError
|
If |
Examples:
Source code in src/tsdynamics/_utils/grids.py
| Python | |
|---|---|
56 57 58 59 60 61 62 63 64 65 66 67 68 69 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 148 149 150 151 | |