Skip to content

Commit

Permalink
fix M shortcut for empty plots
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhrisca committed Oct 23, 2023
1 parent 8fa5e55 commit 0bc3252
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
3 changes: 3 additions & 0 deletions src/asammdf/gui/widgets/channel_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}}"
Expand Down
24 changes: 14 additions & 10 deletions src/asammdf/gui/widgets/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/asammdf/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
""" asammdf version module """

__version__ = "7.3.17.dev1"
__version__ = "7.3.17.dev2"

0 comments on commit 0bc3252

Please sign in to comment.