"""Recompute the published SF pay comparison. Python 3; standard library only. Source check: 2026-11-11. Inputs are schedule references, not guaranteed earnings. Run beside sf-nurse-pay-2026-11-11.csv: python reproduce.py """ import csv from decimal import Decimal from pathlib import Path with Path(__file__).with_name("sf-nurse-pay-2026-11-11.csv").open(encoding="utf-8", newline="") as stream: rows = list(csv.DictReader(stream)) assert len(rows) == 10 for row in rows: staff = Decimal(row["staff_hourly_usd"]) per_diem = Decimal(row["per_diem_hourly_usd"]) annual = Decimal(row["staff_annual_reference_usd"]) assert annual == staff * 2080 assert Decimal(row["per_diem_annual_reference_usd"]) == per_diem * 2080 premium = (per_diem / staff - 1) * 100 hours = annual / per_diem print(f"Step {row['step']}: premium {premium:.2f}%; matching paid hours {hours:.2f}") assert abs(premium - Decimal(row["premium_percent"])) < Decimal("0.000001") assert abs(hours - Decimal(row["break_even_paid_hours_cost_0"])) < Decimal("0.000001") print("All 10 source conversions and calculated columns agree.")