From c4ecf29ab93511efc2230139f325e8d82ff73d7c Mon Sep 17 00:00:00 2001 From: Iahn Cajigas Date: Tue, 10 Mar 2026 07:46:41 -0400 Subject: [PATCH] Fix nspikeTrain.plot() to accept handle kwarg for API consistency nspikeTrain.plot() used currentHandle while SignalObj.plot() and nstColl.plot() used handle. Accept both so callers can use a uniform handle= keyword across all plot methods. Found during end-to-end verification of paper example 01. Co-Authored-By: Claude Opus 4.6 --- nstat/core.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nstat/core.py b/nstat/core.py index 4856c68d..09ed57b8 100644 --- a/nstat/core.py +++ b/nstat/core.py @@ -1946,10 +1946,10 @@ def plotExponentialFit(self, minTime: float | None = None, maxTime: float | None fig.tight_layout() return fig - def plot(self, dHeight: float = 1.0, yOffset: float = 0.5, currentHandle=None): + def plot(self, dHeight: float = 1.0, yOffset: float = 0.5, currentHandle=None, handle=None): import matplotlib.pyplot as plt - ax = plt.gca() if currentHandle is None else currentHandle + ax = plt.gca() if (currentHandle is None and handle is None) else (currentHandle or handle) lines = [] for spike_time in self.spikeTimes: (line,) = ax.plot( @@ -1958,7 +1958,7 @@ def plot(self, dHeight: float = 1.0, yOffset: float = 0.5, currentHandle=None): "k", ) lines.append(line) - if currentHandle is None: + if currentHandle is None and handle is None: xunits = f" [{self.xunits}]" if self.xunits else "" yunits = f" [{self.yunits}]" if self.yunits else "" ax.set_xlabel(f"{self.xlabelval}{xunits}")