demovuln
demovuln is a Python package for simulating temporally structured demographic perturbations in matrix population models and estimating integrated population vulnerability.
The package is designed for comparative demographic analyses in which perturbations differ in magnitude, duration, and recurrence. It provides tools to simulate individual perturbation trajectories, evaluate full perturbation grids, and compute an integrated vulnerability metric based on population reduction relative to an unperturbed baseline.
Installation
For local development:
git clone https://github.com/agimenezromero/demovuln.git
cd demovuln
python -m pip install -e ".[dev,docs]"
After publication on PyPI, the package will be installable with:
pip install demovuln
Basic usage
import numpy as np
from demovuln import MatrixPopulationModel, simulate_dynamics
A = np.array([
[0.0, 2.0],
[0.4, 0.7],
])
model = MatrixPopulationModel(A)
result = simulate_dynamics(
model,
target="adult_survival",
magnitude=0.25,
duration=1,
period=3,
t_max=50,
recovery_steps=10,
)
print(result.reduction)
print(result.abundance)
Perturbation-grid analysis
import numpy as np
from demovuln import MatrixPopulationModel, PerturbationGrid, run_grid
A = np.array([
[0.0, 2.0],
[0.4, 0.7],
])
model = MatrixPopulationModel(A)
grid = PerturbationGrid(
magnitudes=np.linspace(0, 1, 11),
durations=[0, 1, 2, 3],
periods=[1, 2, 3, 5, 10],
)
out = run_grid(
model,
target="adult_survival",
grid=grid,
t_max=50,
recovery_steps=10,
)
print(out.vulnerability)
print(out.table.head())
Demographic targets
The package supports perturbations to:
adult_survivaljuvenile_survivalfecundityallcustom
By default, adult stages are inferred as source-stage columns with at least one fecundity entry, and juvenile stages are inferred as the remaining source-stage columns. These definitions can be specified explicitly:
model = MatrixPopulationModel(
A,
adult_stages=[1],
juvenile_stages=[0],
)
Custom perturbation targets can be defined with Boolean masks:
custom_mask = np.array([
[False, False],
[True, False],
])
result = simulate_dynamics(
model,
target="custom",
custom_mask=custom_mask,
magnitude=0.5,
duration=1,
period=3,
t_max=50,
)
Conceptual summary
For a given perturbation regime, population reduction is computed as:
rho = 100 * (1 - N_perturbed(T) / N_baseline(T))
where N_perturbed(T) is the final population size under perturbed dynamics and N_baseline(T) is the final population size under the unperturbed baseline.
Integrated vulnerability is the mean population reduction across the simulated perturbation space:
Phi = mean(rho)
Development checks
Run:
pytest
python examples/basic_usage.py
ruff check demovuln tests examples
sphinx-build -W -b html docs docs/_build/html
Documentation
Local documentation can be built with:
sphinx-build -b html docs docs/_build/html
Then open:
xdg-open docs/_build/html/index.html
Citation
Citation metadata are provided in CITATION.cff.
License
This package is distributed under the MIT License.
Metadata
Release files for demovuln 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| demovuln-0.1.0.tar.gz | 17.4 kB | With provenance | Details for demovuln-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| demovuln-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for demovuln-0.1.0-py3-none-any.whl |
Total release size: 32.7 kB
Release files / demovuln-0.1.0.tar.gz
| Download URL | demovuln-0.1.0.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e7adfea008429064c3f859176a16a6b0fd1c7a2579a21d01651a332e41c353c
|
|
BLAKE2b-256 checksum How to use checksums |
26267c433be29111f8f68237d7778886e232c933d89ce475194ed33c110bcaaf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 19, 2026.
Transparency logRelease files / demovuln-0.1.0-py3-none-any.whl
| Download URL | demovuln-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6ac6f310d41b4982cb720870152f4c72ddf6b45289774a9306a7b342cc908e48
|
|
BLAKE2b-256 checksum How to use checksums |
d38fcae3e6ee84de5ea111d0864d54740128df4b3b3f8c1b8f918b21d6ac8b00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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 19, 2026.
Transparency logSecurity for demovuln 0.1.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for demovuln-0.1.0.tar.gz
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 19, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.