Beispiel #1
0
def test_transform_PlateCarree_shortcut():
    src = ccrs.PlateCarree(central_longitude=0)
    target = ccrs.PlateCarree(central_longitude=180)

    # of the 3 paths, 2 of them cannot be short-cutted.
    pth1 = mpath.Path([[0.5, 0], [10, 10]])
    pth2 = mpath.Path([[0.5, 91], [10, 10]])
    pth3 = mpath.Path([[-0.5, 0], [10, 10]])

    trans = InterProjectionTransform(src, target)

    with mock.patch.object(target, 'project_geometry',
                           wraps=target.project_geometry) as counter:
        trans.transform_path(pth1)
        # pth1 should allow a short-cut.
        counter.assert_not_called()

    with mock.patch.object(target, 'project_geometry',
                           wraps=target.project_geometry) as counter:
        trans.transform_path(pth2)
        counter.assert_called_once()

    with mock.patch.object(target, 'project_geometry',
                           wraps=target.project_geometry) as counter:
        trans.transform_path(pth3)
        counter.assert_called_once()
Beispiel #2
0
def test_transform_PlateCarree_shortcut():
    src = ccrs.PlateCarree(central_longitude=0)
    target = ccrs.PlateCarree(central_longitude=180)

    # of the 3 paths, 2 of them cannot be short-cutted.
    pth1 = mpath.Path([[0.5, 0], [10, 10]])
    pth2 = mpath.Path([[0.5, 91], [10, 10]])
    pth3 = mpath.Path([[-0.5, 0], [10, 10]])

    trans = InterProjectionTransform(src, target)

    counter = CallCounter(target, 'project_geometry')

    with counter:
        trans.transform_path(pth1)
        # pth1 should allow a short-cut.
        assert counter.count == 0

    with counter:
        trans.transform_path(pth2)
        assert counter.count == 1

    with counter:
        trans.transform_path(pth3)
        assert counter.count == 2
Beispiel #3
0
def test_transform_PlateCarree_shortcut():
    src = ccrs.PlateCarree(central_longitude=0)
    target = ccrs.PlateCarree(central_longitude=180)

    # of the 3 paths, 2 of them cannot be short-cutted.
    pth1 = mpath.Path([[0.5, 0], [10, 10]])
    pth2 = mpath.Path([[0.5, 91], [10, 10]])
    pth3 = mpath.Path([[-0.5, 0], [10, 10]])

    trans = InterProjectionTransform(src, target)

    counter = CallCounter(target, 'project_geometry')

    with counter:
        trans.transform_path(pth1)
        # pth1 should allow a short-cut.
        assert_equal(counter.count, 0)

    with counter:
        trans.transform_path(pth2)
        assert_equal(counter.count, 1)

    with counter:
        trans.transform_path(pth3)
        assert_equal(counter.count, 2)