Skip to content

Commit a54d327

Browse files
committed
imports and version comparison fixes2
1 parent 7b80a0d commit a54d327

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

peakdet/editor.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33

44
import functools
55

6+
import matplotlib
67
import matplotlib.pyplot as plt
78
import numpy as np
89
from loguru import logger
910
from matplotlib.widgets import SpanSelector
11+
from packaging.version import Version
1012

1113
from peakdet import operations, utils
1214

@@ -61,35 +63,35 @@ def __init__(self, data):
6163
reject = functools.partial(self.on_edit, method="reject")
6264
insert = functools.partial(self.on_edit, method="insert")
6365

64-
# Check matplotlib version rectprops is deprecated with matplotlib 3.5.0 and then obsolete
65-
if matplotlib.__version__ >= '3.5.0':
66-
property_name = 'props'
66+
# Check matplotlib version rectprops is deprecated with matplotlib 3.5.0 and then obsolete
67+
if Version(matplotlib.__version__) >= Version("3.5.0"):
68+
property_name = "props"
6769
else:
68-
property_name = 'rectprops'
70+
property_name = "rectprops"
6971

7072
self.span2 = SpanSelector(
7173
self.ax,
7274
delete,
7375
"horizontal",
7476
button=1,
7577
useblit=True,
76-
**{property_name: dict(facecolor='red', alpha=0.3)},
78+
**{property_name: dict(facecolor="red", alpha=0.3)},
7779
)
7880
self.span1 = SpanSelector(
7981
self.ax,
8082
reject,
8183
"horizontal",
8284
button=2,
8385
useblit=True,
84-
**{property_name: dict(facecolor='blue', alpha=0.3)},
86+
**{property_name: dict(facecolor="blue", alpha=0.3)},
8587
)
8688
self.span3 = SpanSelector(
8789
self.ax,
8890
insert,
8991
"horizontal",
9092
button=3,
9193
useblit=True,
92-
**{property_name: dict(facecolor='green', alpha=0.3)},
94+
**{property_name: dict(facecolor="green", alpha=0.3)},
9395
)
9496

9597
self.plot_signals(False)

0 commit comments

Comments
 (0)