• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python testing.assert_allclose函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中skimage._shared.testing.assert_allclose函数的典型用法代码示例。如果您正苦于以下问题:Python assert_allclose函数的具体用法?Python assert_allclose怎么用?Python assert_allclose使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了assert_allclose函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_picture_slice

def test_picture_slice():
    array = _array_2d_to_RGBA(np.arange(0, 10)[np.newaxis, :])
    pic = novice.Picture(array=array)

    x_slice = slice(3, 8)
    subpic = pic[:, x_slice]
    assert_allclose(subpic.array, array[x_slice, :])
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:test_novice.py


示例2: test_multi_page_gif

def test_multi_page_gif():
    img = imread(os.path.join(data_dir, 'no_time_for_that_tiny.gif'))
    assert img.shape == (24, 25, 14, 3), img.shape
    img2 = imread(os.path.join(data_dir, 'no_time_for_that_tiny.gif'),
                  img_num=5)
    assert img2.shape == (25, 14, 3)
    assert_allclose(img[5], img2)
开发者ID:Cadair,项目名称:scikit-image,代码行数:7,代码来源:test_pil.py


示例3: check

 def check():
     expected = self.refs[filter]
     result = getattr(rank, filter)(self.image, self.selem)
     if filter == "entropy":
         # There may be some arch dependent rounding errors
         # See the discussions in
         # https://github.com/scikit-image/scikit-image/issues/3091
         # https://github.com/scikit-image/scikit-image/issues/2528
         assert_allclose(expected, result, atol=0, rtol=1E-15)
     elif filter == "otsu":
         # OTSU May also have some optimization dependent failures
         # See the discussions in
         # https://github.com/scikit-image/scikit-image/issues/3091
         # Pixel 3, 5 was found to be problematic. It can take either
         # a value of 41 or 81 depending on the specific optimizations
         # used.
         assert result[3, 5] in [41, 81]
         result[3, 5] = 81
         # Pixel [19, 18] is also found to be problematic for the same
         # reason.
         assert result[19, 18] in [141, 172]
         result[19, 18] = 172
         assert_array_equal(expected, result)
     else:
         assert_array_equal(expected, result)
开发者ID:TheArindham,项目名称:scikit-image,代码行数:25,代码来源:test_rank.py


示例4: test_prewitt_vertical

def test_prewitt_vertical():
    """Prewitt on a vertical edge should be a vertical line."""
    i, j = np.mgrid[-5:6, -5:6]
    image = (j >= 0).astype(float)
    result = filters.prewitt(image) * np.sqrt(2)
    j[np.abs(i) == 5] = 10000
    assert_allclose(result[j == 0], 1)
    assert_allclose(result[np.abs(j) > 1], 0, atol=1e-10)
开发者ID:Cadair,项目名称:scikit-image,代码行数:8,代码来源:test_edges.py


示例5: test_scharr_vertical

def test_scharr_vertical():
    """Scharr on a vertical edge should be a vertical line."""
    i, j = np.mgrid[-5:6, -5:6]
    image = (j >= 0).astype(float)
    result = filters.scharr(image) * np.sqrt(2)
    j[np.abs(i) == 5] = 10000
    assert_allclose(result[j == 0], 1)
    assert (np.all(result[np.abs(j) > 1] == 0))
开发者ID:Cadair,项目名称:scikit-image,代码行数:8,代码来源:test_edges.py


示例6: test_prewitt_v_vertical

def test_prewitt_v_vertical():
    """Vertical prewitt on an edge should be a vertical line."""
    i, j = np.mgrid[-5:6, -5:6]
    image = (j >= 0).astype(float)
    result = filters.prewitt_v(image)
    # Fudge the eroded points
    j[np.abs(i) == 5] = 10000
    assert (np.all(result[j == 0] == 1))
    assert_allclose(result[np.abs(j) > 1], 0, atol=1e-10)
开发者ID:Cadair,项目名称:scikit-image,代码行数:9,代码来源:test_edges.py


示例7: test_4d_input_pixel

def test_4d_input_pixel():
    phantom = img_as_float(binary_blobs(length=32, n_dim=4))
    reference_image = np.fft.fftn(phantom)
    shift = (-2., 1., 5., -3)
    shifted_image = fourier_shift(reference_image, shift)
    result, error, diffphase = register_translation(reference_image,
                                                    shifted_image,
                                                    space="fourier")
    assert_allclose(result, -np.array(shift), atol=0.05)
开发者ID:ThomasWalter,项目名称:scikit-image,代码行数:9,代码来源:test_register_translation.py


示例8: test_prewitt_h_horizontal

def test_prewitt_h_horizontal():
    """Horizontal prewitt on an edge should be a horizontal line."""
    i, j = np.mgrid[-5:6, -5:6]
    image = (i >= 0).astype(float)
    result = filters.prewitt_h(image)
    # Fudge the eroded points
    i[np.abs(j) == 5] = 10000
    assert (np.all(result[i == 0] == 1))
    assert_allclose(result[np.abs(i) > 1], 0, atol=1e-10)
开发者ID:Cadair,项目名称:scikit-image,代码行数:9,代码来源:test_edges.py


示例9: test_sobel_horizontal

def test_sobel_horizontal():
    """Sobel on a horizontal edge should be a horizontal line."""
    i, j = np.mgrid[-5:6, -5:6]
    image = (i >= 0).astype(float)
    result = filters.sobel(image) * np.sqrt(2)
    # Fudge the eroded points
    i[np.abs(j) == 5] = 10000
    assert_allclose(result[i == 0], 1)
    assert (np.all(result[np.abs(i) > 1] == 0))
开发者ID:Cadair,项目名称:scikit-image,代码行数:9,代码来源:test_edges.py


示例10: test_subpixel_precision

def test_subpixel_precision():
    reference_image = np.fft.fftn(camera())
    subpixel_shift = (-2.4, 1.32)
    shifted_image = fourier_shift(reference_image, subpixel_shift)

    # subpixel precision
    result, error, diffphase = register_translation(reference_image,
                                                    shifted_image, 100,
                                                    space="fourier")
    assert_allclose(result[:2], -np.array(subpixel_shift), atol=0.05)
开发者ID:Cadair,项目名称:scikit-image,代码行数:10,代码来源:test_register_translation.py


示例11: test_correlation

def test_correlation():
    reference_image = np.fft.fftn(camera())
    shift = (-7, 12)
    shifted_image = fourier_shift(reference_image, shift)

    # pixel precision
    result, error, diffphase = register_translation(reference_image,
                                                    shifted_image,
                                                    space="fourier")
    assert_allclose(result[:2], -np.array(shift))
开发者ID:Cadair,项目名称:scikit-image,代码行数:10,代码来源:test_register_translation.py


示例12: test_speckle

def test_speckle():
    seed = 42
    data = np.zeros((128, 128)) + 0.1
    np.random.seed(seed=seed)
    noise = np.random.normal(0.1, 0.02 ** 0.5, (128, 128))
    expected = np.clip(data + data * noise, 0, 1)

    data_speckle = random_noise(data, mode='speckle', seed=seed, mean=0.1,
                                var=0.02)
    assert_allclose(expected, data_speckle)
开发者ID:Cadair,项目名称:scikit-image,代码行数:10,代码来源:test_random_noise.py


示例13: test_poisson

def test_poisson():
    seed = 42
    data = camera()  # 512x512 grayscale uint8
    cam_noisy = random_noise(data, mode='poisson', seed=seed)
    cam_noisy2 = random_noise(data, mode='poisson', seed=seed, clip=False)

    np.random.seed(seed=seed)
    expected = np.random.poisson(img_as_float(data) * 256) / 256.
    assert_allclose(cam_noisy, np.clip(expected, 0., 1.))
    assert_allclose(cam_noisy2, expected)
开发者ID:Cadair,项目名称:scikit-image,代码行数:10,代码来源:test_random_noise.py


示例14: test_real_input

def test_real_input():
    reference_image = camera()
    subpixel_shift = (-2.4, 1.32)
    shifted_image = fourier_shift(np.fft.fftn(reference_image), subpixel_shift)
    shifted_image = np.fft.ifftn(shifted_image)

    # subpixel precision
    result, error, diffphase = register_translation(reference_image,
                                                    shifted_image, 100)
    assert_allclose(result[:2], -np.array(subpixel_shift), atol=0.05)
开发者ID:Cadair,项目名称:scikit-image,代码行数:10,代码来源:test_register_translation.py


示例15: test_size_one_dimension_input

def test_size_one_dimension_input():
    # take a strip of the input image
    reference_image = np.fft.fftn(camera()[:, 15]).reshape((-1, 1))
    subpixel_shift = (-2.4, 4)
    shifted_image = fourier_shift(reference_image, subpixel_shift)

    # subpixel precision
    result, error, diffphase = register_translation(reference_image,
                                                    shifted_image, 100,
                                                    space="fourier")
    assert_allclose(result[:2], -np.array((-2.4, 0)), atol=0.05)
开发者ID:Cadair,项目名称:scikit-image,代码行数:11,代码来源:test_register_translation.py


示例16: test_line_profile

def test_line_profile():
    """ Test a line profile using an ndim=2 image"""
    plugin = setup_line_profile(data.camera())
    line_image, scan_data = plugin.output()
    for inp in [line_image.nonzero()[0].size,
                line_image.sum() / line_image.max(),
                scan_data.size]:
        assert_equal(inp, 172)
    assert_equal(line_image.shape, (512, 512))
    assert_allclose(scan_data.max(), 0.9176, rtol=1e-3)
    assert_allclose(scan_data.mean(), 0.2812, rtol=1e-3)
开发者ID:ahojnnes,项目名称:scikit-image,代码行数:11,代码来源:test_plugins.py


示例17: test_salt

def test_salt():
    seed = 42
    cam = img_as_float(camera())
    cam_noisy = random_noise(cam, seed=seed, mode='salt', amount=0.15)
    saltmask = cam != cam_noisy

    # Ensure all changes are to 1.0
    assert_allclose(cam_noisy[saltmask], np.ones(saltmask.sum()))

    # Ensure approximately correct amount of noise was added
    proportion = float(saltmask.sum()) / (cam.shape[0] * cam.shape[1])
    assert 0.11 < proportion <= 0.15
开发者ID:Cadair,项目名称:scikit-image,代码行数:12,代码来源:test_random_noise.py


示例18: test_line_profile_rgb

def test_line_profile_rgb():
    """ Test a line profile using an ndim=3 image"""
    plugin = setup_line_profile(data.chelsea(), limits=None)
    for i in range(6):
        plugin.line_tool._thicken_scan_line()
    line_image, scan_data = plugin.output()
    assert_equal(line_image[line_image == 128].size, 750)
    assert_equal(line_image[line_image == 255].size, 151)
    assert_equal(line_image.shape, (300, 451))
    assert_equal(scan_data.shape, (151, 3))
    assert_allclose(scan_data.max(), 0.772, rtol=1e-3)
    assert_allclose(scan_data.mean(), 0.4359, rtol=1e-3)
开发者ID:ahojnnes,项目名称:scikit-image,代码行数:12,代码来源:test_plugins.py


示例19: test_check_2d

 def test_check_2d(self):
     arr = np.arange(20).reshape(4, 5).astype(np.float64)
     test = pad(arr, (2, 2), mode='linear_ramp', end_values=(0, 0))
     expected = np.array(
         [[0.,   0.,   0.,   0.,   0.,   0.,   0.,    0.,   0.],
          [0.,   0.,   0.,  0.5,   1.,  1.5,   2.,    1.,   0.],
          [0.,   0.,   0.,   1.,   2.,   3.,   4.,    2.,   0.],
          [0.,  2.5,   5.,   6.,   7.,   8.,   9.,   4.5,   0.],
          [0.,   5.,  10.,  11.,  12.,  13.,  14.,    7.,   0.],
          [0.,  7.5,  15.,  16.,  17.,  18.,  19.,   9.5,   0.],
          [0., 3.75,  7.5,   8.,  8.5,   9.,  9.5,  4.75,   0.],
          [0.,   0.,   0.,   0.,   0.,   0.,   0.,    0.,   0.]])
     assert_allclose(test, expected)
开发者ID:Cadair,项目名称:scikit-image,代码行数:13,代码来源:test_arraypad.py


示例20: test_getitem

    def test_getitem(self):
        num = len(self.images)
        for i in range(-num, num):
            assert type(self.images[i]) is np.ndarray
        assert_allclose(self.images[0],
                        self.images[-num])

        def return_img(n):
            return self.images[n]
        with testing.raises(IndexError):
            return_img(num)
        with testing.raises(IndexError):
            return_img(-num - 1)
开发者ID:Cadair,项目名称:scikit-image,代码行数:13,代码来源:test_collection.py



注:本文中的skimage._shared.testing.assert_allclose函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python testing.assert_almost_equal函数代码示例发布时间:2022-05-27
下一篇:
Python testing.assert_函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap