Skip to main content

PYthon RAndom SAmpling for MEshes

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyransame-0.5.0.tar.gz (314.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyransame-0.5.0-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file pyransame-0.5.0.tar.gz.

File metadata

  • Download URL: pyransame-0.5.0.tar.gz
  • Upload date:
  • Size: 314.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pyransame-0.5.0.tar.gz
Algorithm Hash digest
SHA256 e4aa73ebdc21ffadcca8ae96d17ca91e10f59b482fe68ec8d2d7977d132ab3bf
MD5 c21e696bb6602db303681a9f2001a73b
BLAKE2b-256 97f2bfb07b4bd7f4962e92d6da3c37f07a7fb29a7e270fe41ed7431f4b4a2564

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyransame-0.5.0.tar.gz:

Publisher: python-publish.yml on MatthewFlamm/pyransame

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyransame-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pyransame-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for pyransame-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a14ffb2dabc16aef03da6e9cc96b11011798da80f73a5653ccbe50cb54734583
MD5 71e8df929757aade7c9d116c2daddc40
BLAKE2b-256 5f8affe3da8f7632ca1e17ef98f9af1b4fb9b178c2e75f5e9d05046a62f86558

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyransame-0.5.0-py3-none-any.whl:

Publisher: python-publish.yml on MatthewFlamm/pyransame

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page