API Documentation#

random_surface_points(mesh[, n, weights])

Generate random points on surface.

random_surface_dataset(mesh[, n, weights])

Generate random points on surface with sampled data.

random_volume_points(mesh[, n, weights])

Generate random points in a volume.

random_volume_dataset(mesh[, n, weights])

Generate random points in a volume with sampled data.

random_line_points(mesh[, n, weights])

Generate random points on lines.

random_line_dataset(mesh[, n, weights])

Generate random points on lines with sampled data.

random_vertex_points(mesh[, n, weights])

Generate random points from vertices.

random_vertex_dataset(mesh[, n, weights])

Generate random points on vertices with sampled data.

PyVista dataset accessor#

Registered automatically on PyVista >= 0.48 via the pyvista.accessors entry point.

class pyransame.accessor.RansameAccessor(mesh: DataSet)#

Accessor exposing pyransame sampling routines on a dataset.

Available as dataset.ransame once pyransame is imported on PyVista >= 0.48. Each method forwards to the corresponding top-level random_* function in pyransame.

Methods

dataset([n, weights, kind])

Random sampled pyvista.PolyData, dispatched by cell dimension.

line_dataset([n, weights])

Random sampled pyvista.PolyData on line cells.

line_points([n, weights])

Random points on 1D line cells.

points([n, weights, kind])

Random points, dispatched by cell dimension.

surface_dataset([n, weights])

Random sampled pyvista.PolyData on surface cells.

surface_points([n, weights])

Random points on 2D surface cells.

vertex_dataset([n, weights])

Random sampled pyvista.PolyData from vertex cells.

vertex_points([n, weights])

Random points sampled from 0D vertex cells.

volume_dataset([n, weights])

Random sampled pyvista.PolyData in volume cells.

volume_points([n, weights])

Random points in 3D volume cells.

dataset(n: int = 1, weights: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | _NestedSequence[complex | bytes | str] | None = None, *, kind: Literal['vertex', 'line', 'surface', 'volume'] | None = None) PolyData#

Random sampled pyvista.PolyData, dispatched by cell dimension.

Inspects the mesh’s distinct cell types and forwards to the matching random_*_dataset function. Pass kind explicitly to override the inferred dimension on mixed-dimension meshes.

Parameters:
nint, default: 1

Number of random points to generate.

weightsstr or array_like, optional

Per-cell sampling weights, forwarded to the underlying random_*_dataset routine.

kind{“vertex”, “line”, “surface”, “volume”}, optional

Force a specific sampler. When None (the default), the kind is inferred from the cell dimensions present on the mesh and a ValueError is raised if more than one dimension is found.

Returns:
pyvista.PolyData

Sampled mesh with point data interpolated from the input.

Examples

>>> import pyransame  # noqa: F401  (registers ``ransame``)
>>> import pyvista as pv
>>> sampled = pv.Plane().ransame.dataset(5)
>>> sampled.n_points
5
line_dataset(n: int = 1, weights: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | _NestedSequence[complex | bytes | str] | None = None) PolyData#

Random sampled pyvista.PolyData on line cells.

Forwards to pyransame.random_line_dataset(), which returns a pyvista.PolyData with point data interpolated from the input mesh.

line_points(n: int = 1, weights: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | _NestedSequence[complex | bytes | str] | None = None) ndarray#

Random points on 1D line cells.

Forwards to pyransame.random_line_points(). See that function for the full parameter description and supported cell types.

points(n: int = 1, weights: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | _NestedSequence[complex | bytes | str] | None = None, *, kind: Literal['vertex', 'line', 'surface', 'volume'] | None = None) ndarray#

Random points, dispatched by cell dimension.

Inspects the mesh’s distinct cell types and forwards to the matching random_*_points function. Pass kind explicitly to override the inferred dimension on mixed-dimension meshes.

Parameters:
nint, default: 1

Number of random points to generate.

weightsstr or array_like, optional

Per-cell sampling weights, forwarded to the underlying random_*_points routine.

kind{“vertex”, “line”, “surface”, “volume”}, optional

Force a specific sampler. When None (the default), the kind is inferred from the cell dimensions present on the mesh and a ValueError is raised if more than one dimension is found.

Returns:
numpy.ndarray

(n, 3) array of sampled points.

Examples

>>> import pyransame  # noqa: F401  (registers ``ransame``)
>>> import pyvista as pv
>>> pts = pv.Plane().ransame.points(5)
>>> pts.shape
(5, 3)
surface_dataset(n: int = 1, weights: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | _NestedSequence[complex | bytes | str] | None = None) PolyData#

Random sampled pyvista.PolyData on surface cells.

Forwards to pyransame.random_surface_dataset(), which returns a pyvista.PolyData with point data interpolated from the input mesh.

surface_points(n: int = 1, weights: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | _NestedSequence[complex | bytes | str] | None = None) ndarray#

Random points on 2D surface cells.

Forwards to pyransame.random_surface_points(). See that function for the full parameter description and supported cell types.

vertex_dataset(n: int = 1, weights: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | _NestedSequence[complex | bytes | str] | None = None) PolyData#

Random sampled pyvista.PolyData from vertex cells.

Forwards to pyransame.random_vertex_dataset(), which returns a pyvista.PolyData with point data interpolated from the input mesh.

vertex_points(n: int = 1, weights: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | _NestedSequence[complex | bytes | str] | None = None) ndarray#

Random points sampled from 0D vertex cells.

Forwards to pyransame.random_vertex_points(). See that function for the full parameter description and supported cell types.

volume_dataset(n: int = 1, weights: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | _NestedSequence[complex | bytes | str] | None = None) PolyData#

Random sampled pyvista.PolyData in volume cells.

Forwards to pyransame.random_volume_dataset(), which returns a pyvista.PolyData with point data interpolated from the input mesh.

volume_points(n: int = 1, weights: str | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | _NestedSequence[complex | bytes | str] | None = None) ndarray#

Random points in 3D volume cells.

Forwards to pyransame.random_volume_points(). See that function for the full parameter description and supported cell types.