python - 如何检查使用 pytest 调用警告的变量的精确值?
问题描述
我运行 pytest 并得到以下警告信息:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = array([-0.01, -0.01, -0.01, 0.01, 0.01, 0.01])
bounds = (array([-0.01, -0.01, -0.01, -0.01, -0.01, -0.01]), array([0.01, 0.01, 0.01, 0.01, 0.01, 0.01]))
def _check_clip_x(x, bounds):
if (x < bounds[0]).any() or (x > bounds[1]).any():
> warnings.warn("Values in x were outside bounds during a "
"minimize step, clipping to bounds", RuntimeWarning)
E RuntimeWarning: Values in x were outside bounds during a minimize step, clipping to bounds
../../anaconda3/envs/my_env/lib/python3.8/site-packages/scipy/optimize/optimize.py:282: RuntimeWarning
问题是 和 的打印值x
并bounds
没有真正的帮助,因为它们只显示两个小数点。是否可以添加一个选项pytest -W error *.py
来输出完整的浮点形式?
解决方案
推荐阅读
- r - 使用ggplot2沿x轴重新分布列
- mysql - 使用 ? 从 node/express 服务器执行 mysql 查询 占位符出现语法错误 | npm mysql 包
- c++ - 如何在 C++ 中正确打开和关闭文件?
- javascript - 单击列表时HTML更新第二列
- python - 为什么 Python 返回 (2, False, 3) 而不是 True for a, b == 2, 3?
- r - 如何为列表中的每个数据框创建 ggplot 并将它们导出到 R 中?
- google-cloud-platform - 如何将 Cloud CDN 添加到 GCP 虚拟机?始终没有可用的负载均衡器
- sorting - 如何对带有数字的字符串进行数字排序?
- python-3.x - ImportError:无法从“allennlp.data.dataset_readers.dataset_utils”导入名称“Ontonotes”
- flutter - 如何在 Flutter 中的 ListView 元素上设置 onTab