| | from typing import Dict, Any |
| |
|
| |
|
| | def validate_inputs(alpha: float, beta: float, D: float, k: float, R0: float, T: float, n: int, tol: float, eps: float) -> Dict[str, Any]: |
| | errs = [] |
| |
|
| | def _pos(name, x): |
| | if x is None: |
| | errs.append(f"{name} is required.") |
| | return |
| | try: |
| | xv = float(x) |
| | except Exception: |
| | errs.append(f"{name} must be numeric.") |
| | return |
| | if xv <= 0: |
| | errs.append(f"{name} must be > 0.") |
| |
|
| | |
| | _pos("alpha", alpha) |
| | _pos("beta", beta) |
| | if D is None: |
| | errs.append("D is required.") |
| | else: |
| | try: |
| | Dv = float(D) |
| | if Dv < 0: |
| | errs.append("D must be >= 0.") |
| | except Exception: |
| | errs.append("D must be numeric.") |
| |
|
| | if k is None: |
| | errs.append("k is required.") |
| | else: |
| | try: |
| | kv = float(k) |
| | if kv < 0: |
| | errs.append("k must be >= 0.") |
| | except Exception: |
| | errs.append("k must be numeric.") |
| |
|
| | _pos("R0", R0) |
| | _pos("T", T) |
| |
|
| | if n is None: |
| | errs.append("n is required.") |
| | else: |
| | try: |
| | nv = int(n) |
| | if nv < 200: |
| | errs.append("n must be >= 200 for stable plots.") |
| | except Exception: |
| | errs.append("n must be an integer.") |
| |
|
| | if tol is None: |
| | errs.append("tol is required.") |
| | else: |
| | try: |
| | tv = float(tol) |
| | if tv < 0: |
| | errs.append("tol must be >= 0.") |
| | except Exception: |
| | errs.append("tol must be numeric.") |
| |
|
| | _pos("eps", eps) |
| |
|
| | return {"ok": len(errs) == 0, "errors": errs} |