@pytest.mark.parametrize('ambient_dim', [2, 3])
@pytest.mark.parametrize('dformat', ['xml', 'hdf', 'binary'])
def test_unstructured_vertex_grid(ambient_dim, dformat, npoints=64):
    'Test constructing a vertex grid with different ways to define the\n    points and connectivity.\n    '
    from pyvisfile.xdmf import NumpyDataArray, DataArray, _data_item_from_numpy
    connectivity = np.arange(npoints, dtype=np.uint32)
    points = np.random.rand(ambient_dim, npoints)
    if (dformat == 'xml'):
        connectivity = NumpyDataArray(connectivity, name='connectivity')
        points = NumpyDataArray(points.T, name='points')
    elif (dformat in ['hdf', 'binary']):
        if (dformat == 'hdf'):
            cdata = 'geometry.h5:/Grid/Connectivity'
            pdata = 'geometry.h5:/Grid/Points'
        else:
            cdata = 'connectivity.out'
            pdata = 'points.out'
        connectivity = DataArray((_data_item_from_numpy(connectivity, name='connectivity', data=cdata),))
        points = DataArray((_data_item_from_numpy(points.T, name='points', data=pdata),))
    else:
        raise ValueError(f"unknown format: '{dformat}'")
    from pyvisfile.xdmf import TopologyType
    from pyvisfile.xdmf import XdmfUnstructuredGrid
    grid = XdmfUnstructuredGrid(points, connectivity, topology_type=TopologyType.Polyvertex, name='polyvertex')
    from pyvisfile.xdmf import XdmfWriter
    writer = XdmfWriter((grid,))
    filename = f'test_unstructured_vertex_{dformat}_{ambient_dim}d.xmf'
    writer.write_pretty(filename)
Test constructing a vertex grid with different ways to define the
points and connectivity.
@pytest.mark.parametrize('ambient_dim', [2, 3])
@pytest.mark.parametrize('dformat', ['xml', 'hdf', 'binary'])
def test_unstructured_vertex_grid(ambient_dim, dformat, npoints=64):
    'Test constructing a vertex grid with different ways to define the\n    points and connectivity.\n    '
    from pyvisfile.xdmf import NumpyDataArray, DataArray, _data_item_from_numpy
    connectivity = np.arange(npoints, dtype=np.uint32)
    points = np.random.rand(ambient_dim, npoints)
    if (dformat == 'xml'):
        connectivity = NumpyDataArray(connectivity, name='connectivity')
        points = NumpyDataArray(points.T, name='points')
    elif (dformat in ['hdf', 'binary']):
        if (dformat == 'hdf'):
            cdata = 'geometry.h5:/Grid/Connectivity'
            pdata = 'geometry.h5:/Grid/Points'
        else:
            cdata = 'connectivity.out'
            pdata = 'points.out'
        connectivity = DataArray((_data_item_from_numpy(connectivity, name='connectivity', data=cdata),))
        points = DataArray((_data_item_from_numpy(points.T, name='points', data=pdata),))
    else:
        raise ValueError(f"unknown format: '{dformat}'")
    from pyvisfile.xdmf import TopologyType
    from pyvisfile.xdmf import XdmfUnstructuredGrid
    grid = XdmfUnstructuredGrid(points, connectivity, topology_type=TopologyType.Polyvertex, name='polyvertex')
    from pyvisfile.xdmf import XdmfWriter
    writer = XdmfWriter((grid,))
    filename = f'test_unstructured_vertex_{dformat}_{ambient_dim}d.xmf'
    writer.write_pretty(filename)