I found this while checking optimize.py and its tests. There is a filterwarnings("ignore", "", UserWarning) call inside optimize(), but looks like the filter stays active after the function is already done. I tried this on current joss2.0 python 3.13:
import warnings
import numpy as np
from pynumdiff.optimize import optimize
from pynumdiff.smooth_finite_difference import butterdiff
x = np.sin(np.linspace(0, 2*np.pi, 40))
truth = np.cos(np.linspace(0, 2*np.pi, 40))
warnings.resetwarnings()
print(warnings.filters)
optimize(
butterdiff,
x,
1.0,
dxdt_truth=truth,
parallel=False,
maxiter=1,
search_space_updates={
"filter_order": 2,
"cutoff_freq": [0.1],
"num_iterations": 1,
},
)
print(warnings.filters)
warnings.warn("test warning”)
After optimize() the filters are:
[('ignore', None, <class 'UserWarning'>, None, 0)]
and the last warning doesn't print. So one optimizer call can also hide unrelated warnings later in the same python process.
Maybe the filtering should stay local to the optimizer call and restore whatever filters the caller had before?
Review reference: openjournals/joss-reviews#11172
I found this while checking optimize.py and its tests. There is a filterwarnings("ignore", "", UserWarning) call inside optimize(), but looks like the filter stays active after the function is already done. I tried this on current joss2.0 python 3.13:
After optimize() the filters are:
and the last warning doesn't print. So one optimizer call can also hide unrelated warnings later in the same python process.
Maybe the filtering should stay local to the optimizer call and restore whatever filters the caller had before?
Review reference: openjournals/joss-reviews#11172