It seems as though some scipy modules are messing with my warning filters. Consider the following code. My understanding is that it should only throw one warning because of the "once" filter I supplied to my custom Warning class. However, the warning after the scipy import gets shown as well. This is with python 3.7 and scipy 1.6.3.
import warnings class W(DeprecationWarning): pass warnings.simplefilter("once", W) warnings.warn('warning!', W) warnings.warn('warning!', W) from scipy import interpolate warnings.warn('warning!', W) This only seems to happen when I import certain scipy modules. A generic "import scipy" doesn't do this.
I've narrowed it down to the filters set in scipy.special.sf_error.py and scipy.sparse.__init__.py. I don't see how that code would cause the problem, but it does. When I comment those filtersout, my code works as expected.
Am I misunderstanding something? Is there a work-around that that doesn't involved overwriting warnings.filterwarnings/warnings.simplefilters?
没有评论:
发表评论