spright
raw JSON → 25.6.3 verified Sat May 09 auth: no python
Bayesian radius-density-mass relation for small planets, using a hierarchical Bayesian model to infer interior composition from observed mass and radius. Current version 25.6.3, released monthly.
pip install spright Common errors
error AttributeError: module 'spright' has no attribute 'mcmc' ↓
cause The module-level function mcmc was removed in version 25.0.0.
fix
Use the class-based API: from spright import SPRight; model = SPRight(); samples = model.predict(mass, radius).
error ValueError: Input mass and radius must be 1D arrays or scalars. ↓
cause predict() expects scalar or 1D array inputs; passing 2D arrays or lists of lists raises this error.
fix
Flatten your inputs: mass = np.array(mass).ravel(); radius = np.array(radius).ravel().
Warnings
breaking SPRight no longer supports direct instantiation with a config dictionary; use the default constructor. ↓
fix Remove config argument; set parameters via environment variables or the new SPRightConfig object if needed.
deprecated The function 'spright.mcmc' has been deprecated in favor of the class-based API. ↓
fix Replace calls to spright.mcmc with SPRight().predict().
gotcha Mass and radius must be in Earth units (M_earth, R_earth); using SI units will produce incorrect results. ↓
fix Convert masses and radii to Earth units before calling predict.
Imports
- SPRight
from spright import SPRight
Quickstart
from spright import SPRight
# Initialize the model
model = SPRight()
# Evaluate the posterior for a given radius and mass (Earth units)
radius = 1.5 # R_earth
mass = 3.0 # M_earth
# Get posterior samples of core mass fraction and water mass fraction
samples = model.predict(mass, radius)
print(samples)