1010# Lorenz system fixed point:
1111x_bar = [- np .sqrt (beta * (rho - 1 )), - np .sqrt (beta * (rho - 1 )), rho - 1 ]
1212
13+ # True linear operator at the fixed point:
14+ A_true = np .array (
15+ [
16+ [- sigma , sigma , 0.0 ],
17+ [1.0 , - 1.0 , np .sqrt (beta * (rho - 1 ))],
18+ [- np .sqrt (beta * (rho - 1 )), - np .sqrt (beta * (rho - 1 )), - beta ],
19+ ]
20+ )
21+
1322# Settings to replicate odeint defaults.
1423solve_ivp_opts = {}
1524solve_ivp_opts ["rtol" ] = 1e-12
@@ -140,13 +149,6 @@ def test_linear():
140149 lando .fit (X , Y )
141150 lando .analyze_fixed_point (x_bar , compute_A = True )
142151
143- A_true = np .array (
144- [
145- [- sigma , sigma , 0.0 ],
146- [1.0 , - 1.0 , np .sqrt (beta * (rho - 1 ))],
147- [- np .sqrt (beta * (rho - 1 )), - np .sqrt (beta * (rho - 1 )), - beta ],
148- ]
149- )
150152 eigs_true , modes_true = np .linalg .eig (A_true )
151153 modes_rescale = np .divide (lando .modes [0 ], modes_true [0 ])
152154 modes_true_rescaled = np .multiply (modes_true , modes_rescale )
@@ -158,13 +160,18 @@ def test_linear():
158160
159161def test_nonlinear ():
160162 """
161- Test that the nonlinear operator has the correct shape .
163+ Test that the nonlinear operator is accurate .
162164 """
163165 lando = LANDO (** lando_params )
164166 lando .fit (X , Y )
165167 lando .analyze_fixed_point (x_bar )
166168 assert lando .nonlinear (X ).shape == X .shape
167169
170+ X_centered = X - np .array (x_bar )[..., None ]
171+ N_est = lando .nonlinear (X_centered )
172+ N_true = Y - A_true .dot (X_centered )
173+ assert relative_error (N_est , N_true ) < 1e-4
174+
168175
169176def test_predict_1 ():
170177 """
0 commit comments