Skip to main content

pyransame

PYthon RAndom SAmpling for MEshes

Documentation

Utilities for choosing random samples of points within cells of PyVista meshes. This package does not choose random points that define the mesh itself, rather random points on 0D vertices, 1D lines, 2D surfaces or in 3D volumes are sampled.

All linear1 cells from vtk are supported, except for vtkConvexPointSet.

PyVista dataset accessor

On PyVista 0.48+, pip install pyransame registers a ransame accessor on every PyVista dataset. No extra import or registration step is required. PyVista discovers the accessor through the pyvista.accessors entry point and loads it lazily the first time mesh.ransame is used.

import pyvista as pv
from pyvista import examples

bunny = examples.download_bunny()
points = bunny.ransame.surface_points(500)        # numpy array, shape (500, 3)
sampled = bunny.ransame.surface_dataset(500)      # pyvista.PolyData with interpolated arrays

The accessor mirrors the top-level functions:

Method Equivalent function
mesh.ransame.surface_points(n) pyransame.random_surface_points
mesh.ransame.surface_dataset(n) pyransame.random_surface_dataset
mesh.ransame.volume_points(n) pyransame.random_volume_points
mesh.ransame.volume_dataset(n) pyransame.random_volume_dataset
mesh.ransame.line_points(n) pyransame.random_line_points
mesh.ransame.line_dataset(n) pyransame.random_line_dataset
mesh.ransame.vertex_points(n) pyransame.random_vertex_points
mesh.ransame.vertex_dataset(n) pyransame.random_vertex_dataset
mesh.ransame.points(n) dispatch by cell dimension
mesh.ransame.dataset(n) dispatch by cell dimension

points and dataset infer the sampler from the cell dimensions on the mesh: vertex (0D), line (1D), surface (2D), or volume (3D). Mixed dimensions raise ValueError. Pass kind="vertex" | "line" | "surface" | "volume" to override:

sampled = mixed_mesh.ransame.dataset(500, kind="surface")

On older PyVista releases the package still installs and imports cleanly; only the mesh.ransame namespace is unavailable. Use the top-level pyransame.random_* functions in that case.

Random sampling on a 2D surface

Samples on a bunny

Random sampling in a 3D volume

Samples inside a 3D volume

  1. Linear here means not inheriting from vtkNonLinearCell. ↩

Metadata

Release files for pyransame 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyransame 0.5.0
File Size Uploaded
pyransame-0.5.0.tar.gz 314.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyransame 0.5.0
File Interpreter ABI Platform
pyransame-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 329.8 kB

Release files / pyransame-0.5.0.tar.gz

Download URL pyransame-0.5.0.tar.gz
Size 314.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e4aa73ebdc21ffadcca8ae96d17ca91e10f59b482fe68ec8d2d7977d132ab3bf
BLAKE2b-256 checksum
How to use checksums
97f2bfb07b4bd7f4962e92d6da3c37f07a7fb29a7e270fe41ed7431f4b4a2564
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 12, 2026.

Transparency log

Release files / pyransame-0.5.0-py3-none-any.whl

Download URL pyransame-0.5.0-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a14ffb2dabc16aef03da6e9cc96b11011798da80f73a5653ccbe50cb54734583
BLAKE2b-256 checksum
How to use checksums
5f8affe3da8f7632ca1e17ef98f9af1b4fb9b178c2e75f5e9d05046a62f86558
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page