Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions glue/sample/src/sinter/_data/_anon_task_stats.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import collections
import dataclasses
from typing import Counter, Union, TYPE_CHECKING
import numpy as np

if TYPE_CHECKING:
from sinter._data._task_stats import TaskStats
from typing import Counter


@dataclasses.dataclass(frozen=True)
Expand Down Expand Up @@ -35,16 +31,10 @@ class AnonTaskStats:
custom_counts: Counter[str] = dataclasses.field(default_factory=collections.Counter)

def __post_init__(self):
assert isinstance(self.errors, (int, np.integer))
assert isinstance(self.shots, (int, np.integer))
assert isinstance(self.discards, (int, np.integer))
assert isinstance(self.seconds, (int, float, np.integer, np.floating))
assert isinstance(self.custom_counts, collections.Counter)
assert self.errors >= 0
assert self.discards >= 0
assert self.seconds >= 0
assert self.shots >= self.errors + self.discards
assert all(isinstance(k, str) and isinstance(v, (int, np.integer)) for k, v in self.custom_counts.items())

def __repr__(self) -> str:
terms = []
Expand Down Expand Up @@ -80,10 +70,10 @@ def __add__(self, other: 'AnonTaskStats') -> 'AnonTaskStats':
"""
if isinstance(other, AnonTaskStats):
return AnonTaskStats(
shots=self.shots + other.shots,
errors=self.errors + other.errors,
discards=self.discards + other.discards,
seconds=self.seconds + other.seconds,
shots=int(self.shots + other.shots),
errors=int(self.errors + other.errors),
discards=int(self.discards + other.discards),
seconds=float(self.seconds + other.seconds),
custom_counts=self.custom_counts + other.custom_counts,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def classify_discards_and_errors(
out_count_observable_error_combos[err_key] += 1

num_errors = np.count_nonzero(fail_mask)
return num_discards, num_errors
return int(num_discards), int(num_errors)


class DiskDecoder(CompiledDecoder):
Expand Down
Loading