Registry / ai-ml / mp-pyrho

mp-pyrho

JSON →
library0.5.1pypypi✓ verified 83d ago

mp-pyrho is a Python library providing tools for re-gridding periodic volumetric quantum chemistry data (e.g., charge densities, COHP, ELFCAR) into a consistent, resolution-agnostic representation suitable for machine learning applications. It is currently at version 0.5.1 and is actively maintained with a regular release cadence.

pip install mp-pyrho
INSTALL
IMPORT
SIG · MP-PYRHO
M
mp-pyrho
ai-mlpythonv0.5.1
Install
28.5s avg
Import
Disk
607MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
build_error
glibc
py 3.103.910 runs
installs and imports cleanly · install 28.5s · import 0.000s · 568MB
607MB installed
● package 607MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

version
from pyrho import version
from mp_pyrho.grid import RhoGrid
PackageNotFoundError
from pyrho import PackageNotFoundError
from mp_pyrho.grid import RhoGrid

This quickstart demonstrates how to initialize a `RhoGrid` object with a `pymatgen.core.Structure` and dummy 3D volumetric data. It then shows how to use the `regrid` method to standardize the resolution and the `featurize` method to generate a machine-learning-ready representation, either as a 1D vector or a 3D grid.

from pymatgen.core import Structure from mp_pyrho.grid import RhoGrid import numpy as np # Create a dummy structure (e.g., a simple cubic perovskite) structure = Structure.from_spacegroup("Pm-3m", [3.8], ["Fe", "O"], [[0, 0, 0], [0.5, 0.5, 0.5]]) # Create dummy 3D volumetric data (e.g., 20x20x20 points) # In a real scenario, this would be loaded from a CHGCAR, LOCPOT, or similar file dummy_grid_data = np.random.rand(20, 20, 20) # Initialize RhoGrid object with the structure and volumetric data rho_grid = RhoGrid(structure=structure, grid_data=dummy_grid_data) # Regrid the data to a new target resolution (e.g., 0.1 Å) # The output is a 3D NumPy array regridded_data = rho_grid.regrid(target_resolution=0.1) print(f"Original grid shape: {rho_grid.grid_data.shape}") print(f"Shape of regridded data: {regridded_data.shape}") # Featurize the regridded data # For mp-pyrho >= 0.5.0, `vectorize_grid` defaults to True and `center_method` to 'mass' features_vectorized = rho_grid.featurize(target_resolution=0.1) print(f"Shape of features (vectorized): {features_vectorized.shape}") # If you need the 3D grid output from featurize, set vectorize_grid=False features_3d_grid = rho_grid.featurize(target_resolution=0.1, vectorize_grid=False) print(f"Shape of features (3D grid): {features_3d_grid.shape}")
Debug
Known issues
breakingIn `mp-pyrho` version 0.5.0, the default `center_method` for both `RhoGrid.regrid()` and `RhoGrid.featurize()` changed from 'com' (center of mass) to 'mass' (mass-weighted center). This change can lead to different output data if not explicitly handled.
fix
If your previous workflow relied on the 'com' centering, explicitly set `center_method='com'` in your `regrid()` and `featurize()` calls to maintain consistency: `rho_grid.regrid(..., center_method='com')`.
affects: >=0.5.0
gotchaIn `mp-pyrho` version 0.5.0, the `featurize()` method's `vectorize_grid` parameter default changed to `True`. This means `featurize()` now returns a 1D NumPy array by default, instead of a 3D grid, which might be unexpected if you are used to previous versions.
fix
If you require the 3D grid output from `featurize()`, explicitly set `vectorize_grid=False`: `rho_grid.featurize(..., vectorize_grid=False)`.
affects: >=0.5.0
gotchaThe library is primarily designed for periodic volumetric data from quantum chemistry calculations (e.g., VASP CHGCAR, LOCPOT). Using non-periodic data or data formats not compatible with `pymatgen`'s structure representation can lead to unexpected errors or incorrect physical interpretations during regridding and featurization.
fix
Ensure your input `structure` and `grid_data` accurately represent a periodic system and that the `grid_data` aligns with the unit cell dimensions. Use `RhoGrid.from_file()` or `RhoGrid.from_directory()` for robust loading of standard VASP outputs.
affects: all
Upgrade
Version history
0.5.1latest on PyPI · released Oct 13, 2025
Audit
Dependencies
pymatgenrequiredCore data structures for materials science and handling VASP outputs.
numpyrequiredFundamental package for numerical operations and array manipulation.
scipyrequiredScientific computing library, likely used for interpolation and spatial algorithms.
Agent activity
9 hits · last 30 days
node
6
Resources
mp-pyrho — pip install mp-pyrho · libregistry