From b063ae2c05b2861eed8bbe06a1ce190ccd97c10a Mon Sep 17 00:00:00 2001 From: Simon Orlob Date: Fri, 30 Jan 2026 11:29:10 +0100 Subject: [PATCH 1/2] enh: add string representation method to Channel class #266 --- src/vitabel/timeseries.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/vitabel/timeseries.py b/src/vitabel/timeseries.py index 5cf6d42..50959ea 100644 --- a/src/vitabel/timeseries.py +++ b/src/vitabel/timeseries.py @@ -580,6 +580,10 @@ def __init__( offset=offset, ) + def __repr__(self) -> str: + """A string representation of the channel.""" + return f"{self.__class__.__name__}({self.name})" + def data_hash(self) -> str: """Return a hash representing the data and the metadata of this channel.""" data = { From deb3d2d18dccc1fbb9a2be915d19c944e3fc214a Mon Sep 17 00:00:00 2001 From: Benjamin Hackl Date: Mon, 2 Feb 2026 17:29:40 +0100 Subject: [PATCH 2/2] test: add test_channel_repr for Channel __repr__ method --- tests/test_timeseries.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_timeseries.py b/tests/test_timeseries.py index 6e098cb..6f0f4bc 100644 --- a/tests/test_timeseries.py +++ b/tests/test_timeseries.py @@ -288,6 +288,14 @@ def test_channel_time_only(): assert channel.is_time_only() +def test_channel_repr(): + time = np.arange(0, 1, 0.1) + data = np.sin(2 * np.pi * time) + channel = Channel(name="HR", time_index=time, data=data) + + assert repr(channel) == "Channel(HR)" + + def test_channel_get_data(): time = np.arange(0, 5, 0.1) data = np.sin(2 * np.pi * time)