Download engine/validation.py from abdessamad-bourkibate/fdrsm-4-threshold-engine: direct link, hf CLI and curl.
- Browser
- Download file 1.71 kB
-
https://huggingface.co/spaces/abdessamad-bourkibate/fdrsm-4-threshold-engine/resolve/main/engine/validation.py
- Command line
-
hf download hf://spaces/abdessamad-bourkibate/fdrsm-4-threshold-engine/engine/validation.py
-
curl -L -o validation.py https://huggingface.co/spaces/abdessamad-bourkibate/fdrsm-4-threshold-engine/resolve/main/engine/validation.py
1.71 kB
| 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.") | |
| # positivity where required | |
| _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} |