首页 > 解决方案 > 如何检查使用 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

问题是 和 的打印值xbounds没有真正的帮助,因为它们只显示两个小数点。是否可以添加一个选项pytest -W error *.py来输出完整的浮点形式?

标签: pythonpytest

解决方案


推荐阅读