python-3.x - 如何忽略 astropy 3.2 中的弃用警告?
问题描述
我最近将 Astropy 更新到了新的 3.2(.1) 版本。突然很多 AstropyDeprecationWarnings 开始出现。我曾经以这种方式处理它们:
from astropy.utils.exceptions import AstropyDeprecationWarning
import warnings
warnings.simplefilter('ignore', category = AstropyDeprecationWarning)
然而,有了这个新的 Astropy 版本,过滤器基本上被忽略了,并且警告不断显示。这不是一个至关重要的问题,代码当然可以工作,但我想摆脱它们,因为它们使输出更难阅读。有没有办法解决这个问题?难道我做错了什么?
谢谢!
编辑:
我经常看到的两个警告是:
WARNING: AstropyDeprecationWarning: astropy.extern.six will be removed in 4.0, use the six module directly if it is still needed [astropy.extern.six]
WARNING: AstropyDeprecationWarning: Composition of model classes will be removed in 4.0 (but composition of model instances is not affected) [astropy.modeling.core]
我认为第二个警告出现是因为这行代码我结合了高斯模型+背景:
model = models.Gaussian1D(amplitude = flux.max()*0.9, mean = 0., stddev = size) \
+ models.Const1D(amplitude = flux.min()*0.9)
我不知道第一个警告来自哪里。我没有明确导入 astropy.extern.six (我实际上不知道它是什么),所以它可能与第二个警告或第三方代码有关。
编辑 v2:
我对此进行了更多调查,因为模型的组合并不像我最初想到的那样对警告负责。显然 astropy.extern.six 警告来自:
from astroquery.ned import Ned
而模型类警告的组成来自:
import photutils as ph
解决方案
推荐阅读
- java - Java 流映射类属性列表到扁平化映射
- java - 使用 Pattern/Matcher 是否比遍历字符串并查找字符更有效?
- python - selenium 包含无法在对话框中找到元素的文本
- google-apps-script - 是否有某些已记录但不受支持的 Google 幻灯片 AppScript?
- laravel - 如何在 laravel 雄辩的关系中通过品牌获得产品类别
- google-sheets - 使用公式自定义格式
- r - 给定另一个数据集的字符串变量,如何创建新变量?
- javascript - 将模板文字与替换一起使用
- r - 转置 data.frame 并计算每列的非 NA 值
- bash - 使用 sed 从具有特殊字符的字符串中删除子字符串