Skip to content

Commit f8315e7

Browse files
committed
Merge branch 'master' of github.com:florisvb/PyNumDiff into fix-first-value
2 parents 8428688 + 9a7237f commit f8315e7

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

pynumdiff/tests/test_diff_methods.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,17 @@ def test_diff_method(diff_method_and_params, request):
108108
else diff_method(x_noisy, dt, params) if isinstance(params, list) else diff_method(x_noisy, dt)
109109

110110
# check x_hat and x_hat_noisy are close to x and that dxdt_hat and dxdt_hat_noisy are close to dxdt
111-
print("]\n[", end="")
111+
#print("]\n[", end="")
112112
for j,(a,b) in enumerate([(x,x_hat), (dxdt,dxdt_hat), (x,x_hat_noisy), (dxdt,dxdt_hat_noisy)]):
113113
l2_error = np.linalg.norm(a - b)
114114
linf_error = np.max(np.abs(a - b))
115115

116-
print(f"({int(np.ceil(np.log10(l2_error))) if l2_error> 0 else -25}, {int(np.ceil(np.log10(linf_error))) if linf_error > 0 else -25})", end=", ")
117-
#print(error_bounds[diff_method])
118-
#log_l2_bound, log_linf_bound = error_bounds[diff_method][i][j]
119-
# assert np.linalg.norm(a - b) < 10**log_l2_bound
120-
# assert np.max(np.abs(a - b)) < 10**log_linf_bound
121-
# if np.linalg.norm(a - b) < 10**(log_l2_bound - 1) or np.max(np.abs(a - b)) < 10**(log_linf_bound - 1):
122-
# print(f"Improvement detected for method {diff_method}")
116+
#print(f"({int(np.ceil(np.log10(l2_error))) if l2_error> 0 else -25}, {int(np.ceil(np.log10(linf_error))) if linf_error > 0 else -25})", end=", ")
117+
log_l2_bound, log_linf_bound = error_bounds[diff_method][i][j]
118+
assert np.linalg.norm(a - b) < 10**log_l2_bound
119+
assert np.max(np.abs(a - b)) < 10**log_linf_bound
120+
if np.linalg.norm(a - b) < 10**(log_l2_bound - 1) or np.max(np.abs(a - b)) < 10**(log_linf_bound - 1):
121+
print(f"Improvement detected for method {diff_method}")
123122

124123
if plot:
125124
axes[i, 0].plot(t, f(t), label=r"$x(t)$")

0 commit comments

Comments
 (0)