|
1 | 1 | import collections |
2 | 2 | import dataclasses |
3 | | -from typing import Counter, Union, TYPE_CHECKING |
4 | | -import numpy as np |
5 | | - |
6 | | -if TYPE_CHECKING: |
7 | | - from sinter._data._task_stats import TaskStats |
| 3 | +from typing import Counter |
8 | 4 |
|
9 | 5 |
|
10 | 6 | @dataclasses.dataclass(frozen=True) |
@@ -35,16 +31,10 @@ class AnonTaskStats: |
35 | 31 | custom_counts: Counter[str] = dataclasses.field(default_factory=collections.Counter) |
36 | 32 |
|
37 | 33 | def __post_init__(self): |
38 | | - assert isinstance(self.errors, (int, np.integer)) |
39 | | - assert isinstance(self.shots, (int, np.integer)) |
40 | | - assert isinstance(self.discards, (int, np.integer)) |
41 | | - assert isinstance(self.seconds, (int, float, np.integer, np.floating)) |
42 | | - assert isinstance(self.custom_counts, collections.Counter) |
43 | 34 | assert self.errors >= 0 |
44 | 35 | assert self.discards >= 0 |
45 | 36 | assert self.seconds >= 0 |
46 | 37 | assert self.shots >= self.errors + self.discards |
47 | | - assert all(isinstance(k, str) and isinstance(v, (int, np.integer)) for k, v in self.custom_counts.items()) |
48 | 38 |
|
49 | 39 | def __repr__(self) -> str: |
50 | 40 | terms = [] |
@@ -80,10 +70,10 @@ def __add__(self, other: 'AnonTaskStats') -> 'AnonTaskStats': |
80 | 70 | """ |
81 | 71 | if isinstance(other, AnonTaskStats): |
82 | 72 | return AnonTaskStats( |
83 | | - shots=self.shots + other.shots, |
84 | | - errors=self.errors + other.errors, |
85 | | - discards=self.discards + other.discards, |
86 | | - seconds=self.seconds + other.seconds, |
| 73 | + shots=int(self.shots + other.shots), |
| 74 | + errors=int(self.errors + other.errors), |
| 75 | + discards=int(self.discards + other.discards), |
| 76 | + seconds=float(self.seconds + other.seconds), |
87 | 77 | custom_counts=self.custom_counts + other.custom_counts, |
88 | 78 | ) |
89 | 79 |
|
|
0 commit comments