test_delay¶
wield.control.algorithms.statespace.dense.test.test_delay
This is a pytest module needing documentation
Functions
|
This is a pytest needing documentation |
This is a pytest needing documentation |
|
This is a pytest needing documentation |
Details
- print_ssd(ssd)[source][github]¶
This is a pytest needing documentation
code
1def print_ssd(ssd): 2 print("B", ssd.B) 3 print("A", ssd.A) 4 print("E", ssd.E) 5 print("C", ssd.C) 6 print("D", ssd.D)
pytest information
This code is wrapped in a pytest function using conventions detailed in Pytest Conventions. The full name of this test, as known by the documentation, is:
wield.control.algorithms.statespace.dense.test.test_delay.print_ssdThe full name is useful when building documentation, to link a reference to this page using
:func:`name`, or directly include it with an autofunction directive. The collapse nodes below show every instance of the test run. There may only be one, but if the test was run multiple times through pytest parametrizations, the list can be longer.
- test_big_delay()[source][github]¶
This is a pytest needing documentation
code
1def test_big_delay(): 2 length_m = 3995 3 delta_t = length_m / c_m_s 4 delta_t = 1 5 axB = mplfigB(Nrows=2) 6 7 idx_ord = 100 8 arm1 = delay_algorithms.bessel_delay_ABCDE(delta_t, order=idx_ord) 9 print_ssd(arm1) 10 11 F_Hz = np.linspace(0.00 / delta_t, 50 / delta_t, 1000) 12 xfer = xfer_algorithms.ss2xfer(*arm1, F_Hz=F_Hz) 13 14 axB.ax0.semilogx(F_Hz, abs(xfer), label="order {}".format(idx_ord)) 15 axB.ax1.plot(F_Hz, np.angle(xfer, deg=True)) 16 17 xfer_delay = np.exp(-2j * np.pi * F_Hz * delta_t) 18 axB.ax1.plot(F_Hz, np.angle(xfer_delay, deg=True), color="magenta", ls="--") 19 axB.ax1.axvline(1 / delta_t / 4) 20 axB.ax1.axvline(2 / delta_t / 4) 21 axB.ax1.axvline(3 / delta_t / 4) 22 axB.ax1.axvline(4 / delta_t / 4) 23 axB.ax0.legend() 24 axB.save(tjoin("test"))
pytest information
This code is wrapped in a pytest function using conventions detailed in Pytest Conventions. The full name of this test, as known by the documentation, is:
wield.control.algorithms.statespace.dense.test.test_delay.test_big_delayThe full name is useful when building documentation, to link a reference to this page using
:func:`name`, or directly include it with an autofunction directive. The collapse nodes below show every instance of the test run. There may only be one, but if the test was run multiple times through pytest parametrizations, the list can be longer.test_big_delay
output
status: failed duration: 0.038s captured errors: def test_big_delay(): length_m = 3995 delta_t = length_m / c_m_s delta_t = 1 axB = mplfigB(Nrows=2) idx_ord = 100 > arm1 = delay_algorithms.bessel_delay_ABCDE(delta_t, order=idx_ord) ../../src/wield/control/algorithms/statespace/dense/test/test_delay.py:71: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../../src/wield/control/algorithms/statespace/dense/delay_algorithms.py:67: in bessel_delay_ABCDE zdict, pdict, k = bessel_delay(delay_s, order=order, rescale=rescale) ../../src/wield/control/algorithms/statespace/dense/delay_algorithms.py:45: in bessel_delay z, p, k = scipy.signal.besselap(order, norm="delay") /opt/conda/lib/python3.12/site-packages/scipy/signal/_filter_design.py:4914: in besselap p = 1/_bessel_zeros(N) /opt/conda/lib/python3.12/site-packages/scipy/signal/_filter_design.py:4786: in _bessel_zeros x = _aberth(f, fp, x0) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ f = <function _bessel_zeros.<locals>.f at 0x7f8b54a46480> fp = <function _bessel_zeros.<locals>.fp at 0x7f8b54a46520> x0 = array([-0.00058824-0.01j , -0.00116471-0.01018214j, -0.00172941-0.01034076j, -0.00228235-0.01047634j, ...38j, -0.00228235+0.01047634j, -0.00172941+0.01034076j, -0.00116471+0.01018214j, -0.00058824+0.01j ]) tol = 1e-15, maxiter = 50 def _aberth(f, fp, x0, tol=1e-15, maxiter=50): """ Given a function `f`, its first derivative `fp`, and a set of initial guesses `x0`, simultaneously find the roots of the polynomial using the Aberth-Ehrlich method. ``len(x0)`` should equal the number of roots of `f`. (This is not a complete implementation of Bini's algorithm.) """ N = len(x0) x = array(x0, complex) beta = np.empty_like(x0) for iteration in range(maxiter): alpha = -f(x) / fp(x) # Newton's method # Model "repulsion" between zeros for k in range(N): beta[k] = np.sum(1/(x[k] - x[k+1:])) beta[k] += np.sum(1/(x[k] - x[:k])) x += alpha / (1 + alpha * beta) if not all(np.isfinite(x)): > raise RuntimeError('Root-finding calculation failed') E RuntimeError: Root-finding calculation failed /opt/conda/lib/python3.12/site-packages/scipy/signal/_filter_design.py:4751: RuntimeError
- test_delay()[source][github]¶
This is a pytest needing documentation
code
1def test_delay(): 2 length_m = 3995 3 delta_t = length_m / c_m_s 4 delta_t = 1 5 axB = mplfigB(Nrows=2) 6 7 for idx_ord in range(1, 7): 8 arm1 = delay_algorithms.bessel_delay_ABCDE(delta_t, order=idx_ord) 9 print_ssd(arm1) 10 11 F_Hz = logspaced(0.01 / delta_t, 2 / delta_t, 1000) 12 13 xfer = xfer_algorithms.ss2xfer(*arm1, F_Hz=F_Hz) 14 15 axB.ax0.semilogx(F_Hz, abs(xfer), label="order {}".format(idx_ord)) 16 axB.ax1.plot(F_Hz, np.angle(xfer, deg=True)) 17 18 xfer_delay = np.exp(-2j * np.pi * F_Hz * delta_t) 19 axB.ax1.plot(F_Hz, np.angle(xfer_delay, deg=True), color="magenta", ls="--") 20 axB.ax1.axvline(1 / delta_t / 4) 21 axB.ax1.axvline(2 / delta_t / 4) 22 axB.ax1.axvline(3 / delta_t / 4) 23 axB.ax1.axvline(4 / delta_t / 4) 24 axB.ax0.legend() 25 axB.save(tjoin("test"))
pytest information
This code is wrapped in a pytest function using conventions detailed in Pytest Conventions. The full name of this test, as known by the documentation, is:
wield.control.algorithms.statespace.dense.test.test_delay.test_delayThe full name is useful when building documentation, to link a reference to this page using
:func:`name`, or directly include it with an autofunction directive. The collapse nodes below show every instance of the test run. There may only be one, but if the test was run multiple times through pytest parametrizations, the list can be longer.test_delay
output
B [[4.]] A [[-2.]] E [[1.]] C [[1.]] D [[-1.]] captured errors: def test_delay(): length_m = 3995 delta_t = length_m / c_m_s delta_t = 1 axB = mplfigB(Nrows=2) for idx_ord in range(1, 7): arm1 = delay_algorithms.bessel_delay_ABCDE(delta_t, order=idx_ord) print_ssd(arm1) F_Hz = logspaced(0.01 / delta_t, 2 / delta_t, 1000) > xfer = xfer_algorithms.ss2xfer(*arm1, F_Hz=F_Hz) ../../src/wield/control/algorithms/statespace/dense/test/test_delay.py:49: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ A = array([[-2.]]), B = array([[4.]]), C = array([[1.]]), D = array([[-1.]]) E = array([[1.]]) F_Hz = array([0.01 , 0.01005318, 0.01010664, 0.01016038, 0.01021441, 0.01026873, 0.01032333, 0.01037823, 0.010433...4 , 1.91691709, 1.9271107 , 1.93735851, 1.94766083, 1.95801792, 1.96843009, 1.97889763, 1.98942084, 2. ]) idx_in = None, idx_out = None def ss2xfer(A, B, C, D, E=None, F_Hz=None, idx_in=None, idx_out=None): > return ss2response_siso( A, B, C, D, E, s = 2j * np.pi * F_Hz, idx_in=idx_in, idx_out=idx_out ) E TypeError: ss2response_siso() got an unexpected keyword argument 's' ../../src/wield/control/algorithms/statespace/dense/xfer_algorithms.py:20: TypeError