Skip to content

Commit 2a6ce72

Browse files
author
Benjamin Moody
committed
Merge pull request MIT-LCP#386 into main
This renames a number of internal functions to make it clear they are not meant to be part of the public package API.
2 parents 0f3cd0d + e01bf7a commit 2a6ce72

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

tests/test_plot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def test_get_plot_dims(self):
180180
ann = wfdb.rdann(
181181
"sample-data/100", "atr", sampfrom=sampfrom, sampto=sampto
182182
)
183-
sig_len, n_sig, n_annot, n_subplots = plot.get_plot_dims(
183+
sig_len, n_sig, n_annot, n_subplots = plot._get_plot_dims(
184184
signal=record.p_signal, ann_samp=[ann.sample]
185185
)
186186

@@ -191,7 +191,7 @@ def test_get_plot_dims(self):
191191

192192
def test_create_figure_single_subplots(self):
193193
n_subplots = 1
194-
fig, axes = plot.create_figure(
194+
fig, axes = plot._create_figure(
195195
n_subplots, sharex=True, sharey=True, figsize=None
196196
)
197197
assert fig is not None
@@ -200,7 +200,7 @@ def test_create_figure_single_subplots(self):
200200

201201
def test_create_figure_multiple_subplots(self):
202202
n_subplots = 5
203-
fig, axes = plot.create_figure(
203+
fig, axes = plot._create_figure(
204204
n_subplots, sharex=True, sharey=True, figsize=None
205205
)
206206
assert fig is not None

wfdb/plot/plot.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -249,17 +249,17 @@ def plot_items(
249249
signal = _expand_channels(signal)
250250

251251
# Figure out number of subplots required
252-
sig_len, n_sig, n_annot, n_subplots = get_plot_dims(signal, ann_samp)
252+
sig_len, n_sig, n_annot, n_subplots = _get_plot_dims(signal, ann_samp)
253253

254254
# Convert sampling_freq and ann_freq to lists if needed
255255
sampling_freq = _get_sampling_freq(sampling_freq, n_sig, fs)
256256
ann_freq = _get_ann_freq(ann_freq, n_annot, fs)
257257

258258
# Create figure
259-
fig, axes = create_figure(n_subplots, sharex, sharey, figsize)
259+
fig, axes = _create_figure(n_subplots, sharex, sharey, figsize)
260260
try:
261261
if signal is not None:
262-
plot_signal(
262+
_plot_signal(
263263
signal,
264264
sig_len,
265265
n_sig,
@@ -271,7 +271,7 @@ def plot_items(
271271
)
272272

273273
if ann_samp is not None:
274-
plot_annotation(
274+
_plot_annotation(
275275
ann_samp,
276276
n_annot,
277277
ann_sym,
@@ -286,7 +286,7 @@ def plot_items(
286286
)
287287

288288
if ecg_grids:
289-
plot_ecg_grids(
289+
_plot_ecg_grids(
290290
ecg_grids,
291291
fs,
292292
sig_units,
@@ -311,7 +311,7 @@ def plot_items(
311311
"signal: {} values".format(n_subplots)
312312
)
313313

314-
label_figure(
314+
_label_figure(
315315
axes,
316316
n_subplots,
317317
time_units,
@@ -334,7 +334,7 @@ def plot_items(
334334
plt.show()
335335

336336

337-
def get_plot_dims(signal, ann_samp):
337+
def _get_plot_dims(signal, ann_samp):
338338
"""
339339
Figure out the number of plot channels.
340340
@@ -393,7 +393,7 @@ def get_plot_dims(signal, ann_samp):
393393
return sig_len, n_sig, n_annot, max(n_sig, n_annot)
394394

395395

396-
def create_figure(n_subplots, sharex, sharey, figsize):
396+
def _create_figure(n_subplots, sharex, sharey, figsize):
397397
"""
398398
Create the plot figure and subplot axes.
399399
@@ -425,7 +425,7 @@ def create_figure(n_subplots, sharex, sharey, figsize):
425425
return fig, axes
426426

427427

428-
def plot_signal(
428+
def _plot_signal(
429429
signal, sig_len, n_sig, fs, time_units, sig_style, axes, sampling_freq=None
430430
):
431431
"""
@@ -503,7 +503,7 @@ def plot_signal(
503503
axes[ch].plot(t, signal[ch], sig_style[ch], zorder=3)
504504

505505

506-
def plot_annotation(
506+
def _plot_annotation(
507507
ann_samp,
508508
n_annot,
509509
ann_sym,
@@ -625,7 +625,7 @@ def plot_annotation(
625625
)
626626

627627

628-
def plot_ecg_grids(ecg_grids, fs, units, time_units, axes, sampling_freq=None):
628+
def _plot_ecg_grids(ecg_grids, fs, units, time_units, axes, sampling_freq=None):
629629
"""
630630
Add ECG grids to the axes.
631631
@@ -668,7 +668,7 @@ def plot_ecg_grids(ecg_grids, fs, units, time_units, axes, sampling_freq=None):
668668
minor_ticks_x,
669669
major_ticks_y,
670670
minor_ticks_y,
671-
) = calc_ecg_grids(
671+
) = _calc_ecg_grids(
672672
auto_ylims[0],
673673
auto_ylims[1],
674674
units[ch],
@@ -702,7 +702,7 @@ def plot_ecg_grids(ecg_grids, fs, units, time_units, axes, sampling_freq=None):
702702
axes[ch].set_ylim(auto_ylims)
703703

704704

705-
def calc_ecg_grids(minsig, maxsig, sig_units, fs, maxt, time_units):
705+
def _calc_ecg_grids(minsig, maxsig, sig_units, fs, maxt, time_units):
706706
"""
707707
Calculate tick intervals for ECG grids.
708708
@@ -779,7 +779,7 @@ def calc_ecg_grids(minsig, maxsig, sig_units, fs, maxt, time_units):
779779
return (major_ticks_x, minor_ticks_x, major_ticks_y, minor_ticks_y)
780780

781781

782-
def label_figure(
782+
def _label_figure(
783783
axes, n_subplots, time_units, sig_name, sig_units, xlabel, ylabel, title
784784
):
785785
"""
@@ -942,7 +942,7 @@ def plot_wfdb(
942942
ylabel,
943943
record_name,
944944
sig_units,
945-
) = get_wfdb_plot_items(
945+
) = _get_wfdb_plot_items(
946946
record=record, annotation=annotation, plot_sym=plot_sym
947947
)
948948

@@ -980,7 +980,7 @@ def plot_wfdb(
980980
)
981981

982982

983-
def get_wfdb_plot_items(record, annotation, plot_sym):
983+
def _get_wfdb_plot_items(record, annotation, plot_sym):
984984
"""
985985
Get items to plot from WFDB objects.
986986

0 commit comments

Comments
 (0)