Skip to main content

A Python library for calculating malaria intervention budgets

Project description

SNT Malaria Budgeting

A Python library for calculating malaria intervention budgets across different countries and time periods.

Installation

Install from PyPI:

pip install snt-malaria-budgeting

Development Installation

For development, clone the repository and install with development dependencies:

pip install -e .[dev]

This installs the package in editable mode along with all development tools (pytest, ruff, mypy, etc.).

Example usage

To fetch budgets for a given country and years:

from snt_malaria_budgeting.core.budget_calculator import get_budget
from snt_malaria_budgeting.models import (
    DEFAULT_COST_ASSUMPTIONS,
    InterventionDetailModel,
)

start_year = 2025
end_year = 2027
# places are a list of ids
interventions = [InterventionDetailModel(code="iptp", type="SP", places=[1001])]
settings = DEFAULT_COST_ASSUMPTIONS

budgets = []
budget_calculator = BudgetCalculator(
    interventions_input=interventions_input,
    settings=settings,
    cost_df=cost_df, # refer to unit tests for an example
    population_df=population_df, # refer to unit tests for an example
    local_currency="EUR",
    spatial_planning_unit="key",
    cost_overrides=[], # optional

)

for year in range(start_year, end_year + 1):
    print(f"Fetching budget for year: {year}")
    interventions_costs = budget_calculator.get_interventions_costs(year)
    places_costs = budget_calculator.get_places_costs(year)
    budgets.append({
        "year": year,
        "interventions": interventions_costs,
        "org_units_costs": places_costs
    })

print(budgets)

Development

Running Tests

After installing with development dependencies, run the test suite:

pytest
pytest -v # verbose output
pytest --cov=snt_malaria_budgeting --cov-report=html # with coverage report

# specific test files or methods:
pytest tests/core/test_budget_calculator.py
pytest tests/core/test_budget_calculator.py::TestGetBudget::test_get_budget_iptp

Acknowledgements

This library is a Python port of the PATH Budget Generation Function (R implementation).

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

snt_malaria_budgeting-0.4.2.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

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

snt_malaria_budgeting-0.4.2-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file snt_malaria_budgeting-0.4.2.tar.gz.

File metadata

  • Download URL: snt_malaria_budgeting-0.4.2.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for snt_malaria_budgeting-0.4.2.tar.gz
Algorithm Hash digest
SHA256 93255c0fb3b1055c497f1751c558fe4f55a4e711f6f14d4dd6edeb7bc5c76882
MD5 69dedafcfacadb45b3dd4470fed6dde6
BLAKE2b-256 1a6623af2e5a50c44205857827da570e3d574252437c6c722f5b16c614a93ac3

See more details on using hashes here.

File details

Details for the file snt_malaria_budgeting-0.4.2-py3-none-any.whl.

File metadata

File hashes

Hashes for snt_malaria_budgeting-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 297bff0ea9ea10f02774e68766ed63aa0c63128c7f15075d27aa4c19d041db5d
MD5 fdf0fc28d9c5871b455c5986d3a08a24
BLAKE2b-256 229ca1e0ae4b8367adf849d927a08f460dd7e5a10865552baeced08713af67b4

See more details on using hashes here.

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