From 0ea6ac52fd642574071dcbe14c6f30317a4d1c2a Mon Sep 17 00:00:00 2001 From: afni-dglen Date: Thu, 18 Jul 2024 18:54:06 -0400 Subject: [PATCH 1/3] redoing matplotlib deprecation fix --- peakdet/editor.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/peakdet/editor.py b/peakdet/editor.py index c723ae4..2168b40 100644 --- a/peakdet/editor.py +++ b/peakdet/editor.py @@ -60,13 +60,20 @@ def __init__(self, data): delete = functools.partial(self.on_edit, method="delete") reject = functools.partial(self.on_edit, method="reject") insert = functools.partial(self.on_edit, method="insert") + + # Check matplotlib version rectprops is deprecated with matplotlib 3.5.0 and then obsolete + if matplotlib.__version__ >= '3.5.0': + property_name = 'props' + else: + property_name = 'rectprops' + self.span2 = SpanSelector( self.ax, delete, "horizontal", button=1, useblit=True, - rectprops=dict(facecolor="red", alpha=0.3), + **{property_name: dict(facecolor='red', alpha=0.3)}, ) self.span1 = SpanSelector( self.ax, @@ -74,7 +81,7 @@ def __init__(self, data): "horizontal", button=2, useblit=True, - rectprops=dict(facecolor="blue", alpha=0.3), + **{property_name: dict(facecolor='blue', alpha=0.3)}, ) self.span3 = SpanSelector( self.ax, @@ -82,7 +89,7 @@ def __init__(self, data): "horizontal", button=3, useblit=True, - rectprops=dict(facecolor="green", alpha=0.3), + **{property_name: dict(facecolor='green', alpha=0.3)}, ) self.plot_signals(False) From 7b80a0d1a2608a9274677cef84881319f6a253ee Mon Sep 17 00:00:00 2001 From: afni-dglen Date: Thu, 18 Jul 2024 19:01:32 -0400 Subject: [PATCH 2/3] setup.cfg - removing some matplotlib constraints --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 411ee9f..4c40e59 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,7 +21,7 @@ provides = [options] python_requires = >=3.6.1 install_requires = - matplotlib >=3.1.1, <=3.6.3, !=3.3.0rc1 + matplotlib >=3.1.1 numpy >=1.9.3 scipy loguru From a54d327505416b523b80e3f01e7009fcc2ce7e17 Mon Sep 17 00:00:00 2001 From: afni-dglen Date: Fri, 19 Jul 2024 13:22:32 -0400 Subject: [PATCH 3/3] imports and version comparison fixes2 --- peakdet/editor.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/peakdet/editor.py b/peakdet/editor.py index 2168b40..e3cd0ba 100644 --- a/peakdet/editor.py +++ b/peakdet/editor.py @@ -3,10 +3,12 @@ import functools +import matplotlib import matplotlib.pyplot as plt import numpy as np from loguru import logger from matplotlib.widgets import SpanSelector +from packaging.version import Version from peakdet import operations, utils @@ -61,11 +63,11 @@ def __init__(self, data): reject = functools.partial(self.on_edit, method="reject") insert = functools.partial(self.on_edit, method="insert") - # Check matplotlib version rectprops is deprecated with matplotlib 3.5.0 and then obsolete - if matplotlib.__version__ >= '3.5.0': - property_name = 'props' + # Check matplotlib version rectprops is deprecated with matplotlib 3.5.0 and then obsolete + if Version(matplotlib.__version__) >= Version("3.5.0"): + property_name = "props" else: - property_name = 'rectprops' + property_name = "rectprops" self.span2 = SpanSelector( self.ax, @@ -73,7 +75,7 @@ def __init__(self, data): "horizontal", button=1, useblit=True, - **{property_name: dict(facecolor='red', alpha=0.3)}, + **{property_name: dict(facecolor="red", alpha=0.3)}, ) self.span1 = SpanSelector( self.ax, @@ -81,7 +83,7 @@ def __init__(self, data): "horizontal", button=2, useblit=True, - **{property_name: dict(facecolor='blue', alpha=0.3)}, + **{property_name: dict(facecolor="blue", alpha=0.3)}, ) self.span3 = SpanSelector( self.ax, @@ -89,7 +91,7 @@ def __init__(self, data): "horizontal", button=3, useblit=True, - **{property_name: dict(facecolor='green', alpha=0.3)}, + **{property_name: dict(facecolor="green", alpha=0.3)}, ) self.plot_signals(False)