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 = { 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)