Skip to content

Commit 8f383da

Browse files
committed
Add a nice str representation for Sample
Easier to read & compare, especially when debugging. Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent 303afd7 commit 8f383da

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/frequenz/sdk/timeseries/_base_types.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ class Sample(Generic[QuantityT]):
3434
value: QuantityT | None = None
3535
"""The value of this sample."""
3636

37+
def __str__(self) -> str:
38+
"""Return a string representation of the sample."""
39+
return f"Sample({str(self.timestamp)}, {str(self.value)})"
40+
3741

3842
@dataclass(frozen=True)
3943
class Sample3Phase(Generic[QuantityT]):

0 commit comments

Comments
 (0)