(self, val, n=1)
| 271 | self._allow_updates = True |
| 272 | |
| 273 | def update(self, val, n=1): |
| 274 | if n <= 0: |
| 275 | raise ValueError(f"n must be positive, got {n}") |
| 276 | |
| 277 | self.val = val |
| 278 | self.sum += val * n |
| 279 | self.count += n |
| 280 | self.avg = self.sum / self.count if self.count > 0 else 0.0 |
| 281 | |
| 282 | def __str__(self) -> str: |
| 283 | """String representation showing current and average values.""" |
no outgoing calls
no test coverage detected