diff --git a/src/asammdf/gui/widgets/channel_stats.py b/src/asammdf/gui/widgets/channel_stats.py index 363cd1a23..40e61e326 100644 --- a/src/asammdf/gui/widgets/channel_stats.py +++ b/src/asammdf/gui/widgets/channel_stats.py @@ -57,6 +57,9 @@ def __init__(self, xunit="s", precision=6, *args, **kwargs): self.precision.currentIndexChanged.connect(self.set_float_precision) def set_stats(self, stats): + if not stats: + return + self._stats = deepcopy(stats) precision = self._settings.value("stats_float_precision", 6, type=int) fmt = f" {{:.{precision}f}}" diff --git a/src/asammdf/gui/widgets/plot.py b/src/asammdf/gui/widgets/plot.py index 06eccc6c4..8371fd3f8 100644 --- a/src/asammdf/gui/widgets/plot.py +++ b/src/asammdf/gui/widgets/plot.py @@ -2635,8 +2635,9 @@ def keyPressEvent(self, event): ) ) - stats = self.plot.get_stats(self.info_uuid) - self.info.set_stats(stats) + if self.info_uuid: + stats = self.plot.get_stats(self.info_uuid) + self.info.set_stats(stats) elif key == QtCore.Qt.Key.Key_2 and modifiers == QtCore.Qt.KeyboardModifier.NoModifier: self.focused_mode = not self.focused_mode @@ -4294,14 +4295,17 @@ def get_current_timebase(self): return self.all_timebase def get_stats(self, uuid): - sig, index = self.signal_by_uuid(uuid) - - return sig.get_stats( - cursor=self.cursor1.value() if self.cursor1 else None, - region=self.region.getRegion() if self.region else None, - view_region=self.viewbox.viewRange()[0], - precision=self._settings.value("stats_float_precision", sig.precision, type=int), - ) + try: + sig, index = self.signal_by_uuid(uuid) + except KeyError: + return {} + else: + return sig.get_stats( + cursor=self.cursor1.value() if self.cursor1 else None, + region=self.region.getRegion() if self.region else None, + view_region=self.viewbox.viewRange()[0], + precision=self._settings.value("stats_float_precision", sig.precision, type=int), + ) def get_timestamp_index(self, timestamp, timestamps): key = id(timestamps), timestamp diff --git a/src/asammdf/version.py b/src/asammdf/version.py index a7e579197..2ed042213 100644 --- a/src/asammdf/version.py +++ b/src/asammdf/version.py @@ -1,3 +1,3 @@ """ asammdf version module """ -__version__ = "7.3.17.dev1" +__version__ = "7.3.17.dev2"