@requires_shapely
def test_shapely_to_cf(geometry_ds):
    from shapely.geometry import Point
    (expected, in_ds) = geometry_ds
    out = xr.merge([in_ds.drop_vars('geometry'), cfxr.shapely_to_cf(in_ds.geometry)])
    xr.testing.assert_identical(out, expected)
    out = xr.merge([in_ds.drop_vars('geometry').isel(index=slice(1, None)), cfxr.shapely_to_cf(in_ds.geometry.isel(index=slice(1, None)))])
    expected = expected.isel(index=slice(1, None), node=slice(2, None)).drop_vars('node_count')
    del expected.geometry_container.attrs['node_count']
    xr.testing.assert_identical(out, expected)
    out = xr.merge([in_ds.drop_vars('geometry').isel(index=slice(1, None)), cfxr.shapely_to_cf(in_ds.geometry.isel(index=slice(1, None)), grid_mapping='longitude_latitude')])
    np.testing.assert_array_equal(out.lon, expected.crd_x)
    assert ('longitude' in out.cf)
    assert ('latitude' in out.cf)
    out = cfxr.shapely_to_cf([Point(2, 3)])
    assert (set(out.dims) == {'features', 'node'})
@requires_shapely
def test_shapely_to_cf(geometry_ds):
    from shapely.geometry import Point
    (expected, in_ds) = geometry_ds
    out = xr.merge([in_ds.drop_vars('geometry'), cfxr.shapely_to_cf(in_ds.geometry)])
    xr.testing.assert_identical(out, expected)
    out = xr.merge([in_ds.drop_vars('geometry').isel(index=slice(1, None)), cfxr.shapely_to_cf(in_ds.geometry.isel(index=slice(1, None)))])
    expected = expected.isel(index=slice(1, None), node=slice(2, None)).drop_vars('node_count')
    del expected.geometry_container.attrs['node_count']
    xr.testing.assert_identical(out, expected)
    out = xr.merge([in_ds.drop_vars('geometry').isel(index=slice(1, None)), cfxr.shapely_to_cf(in_ds.geometry.isel(index=slice(1, None)), grid_mapping='longitude_latitude')])
    np.testing.assert_array_equal(out.lon, expected.crd_x)
    assert ('longitude' in out.cf)
    assert ('latitude' in out.cf)
    out = cfxr.shapely_to_cf([Point(2, 3)])
    assert (set(out.dims) == {'features', 'node'})