Spaces:
Runtime error
Runtime error
Download simulator/issues/base.py from autodrive/dq-simulator: direct link, hf CLI and curl.
- Browser
- Download file 685 Bytes
-
https://huggingface.co/spaces/autodrive/dq-simulator/resolve/main/simulator/issues/base.py
- Command line
-
hf download hf://spaces/autodrive/dq-simulator/simulator/issues/base.py
-
curl -L -o base.py https://huggingface.co/spaces/autodrive/dq-simulator/resolve/main/simulator/issues/base.py
685 Bytes
| """Base Issue class.""" | |
| from dataclasses import dataclass, field | |
| from typing import Callable | |
| import numpy as np | |
| import pandas as pd | |
| class Issue: | |
| id: str | |
| name: str | |
| category: str | |
| description: str | |
| severity: str # low | medium | high | critical | |
| default_rate: float | |
| inject: Callable[[pd.DataFrame, float, np.random.Generator], pd.DataFrame] | |
| def __str__(self): | |
| return f"[{self.severity.upper()}] {self.id} ({self.category}): {self.description}" | |
| def pick_rows(df: pd.DataFrame, rate: float, rng: np.random.Generator) -> np.ndarray: | |
| """Return boolean mask selecting ~rate fraction of rows.""" | |
| return rng.random(len(df)) < rate | |