Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在函数skimage.img_作为单元捕获警告_Python_Warnings_Scikit Image - Fatal编程技术网

Python 在函数skimage.img_作为单元捕获警告

Python 在函数skimage.img_作为单元捕获警告,python,warnings,scikit-image,Python,Warnings,Scikit Image,我尝试了两个警告。catch\u warnings()和输入参数force\u copy 两者都未能捕获转换警告 import numpy as np import skimage import warnings mm = np.ones([55,55],dtype=np.float32) with warnings.catch_warnings(): dd = skimage.img_as_uint(mm,force_copy=True) 给予 XXX/lib/python2.7

我尝试了两个警告。catch\u warnings()和输入参数
force\u copy
两者都未能捕获转换警告

import numpy as np
import skimage
import warnings

mm = np.ones([55,55],dtype=np.float32)
with warnings.catch_warnings():
     dd = skimage.img_as_uint(mm,force_copy=True)
给予

XXX/lib/python2.7/site-packages/skimage/util/dtype.py:130: UserWarning: Possible precision loss
when converting from float32 to uint16.format(dtypeobj_in, dtypeobj_out))


您需要添加一行,
警告。simplefilter('ignore')

将numpy导入为np
进口撇渣
进口警告
mm=np.one([55,55],dtype=np.float32)
带有警告。捕获警告()
警告。simplefilter('忽略')
dd=撇印。img作为单位(毫米,强制复制=真)
有关更多信息,请参阅