Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve matplotlib deprecation issue #74

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions peakdet/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,36 @@ 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':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to explicitly import matplotlib for this. The current imports don't cover this. This is also indicated in the pre-commit fail

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comparison does not work consistently. E.g. from my ipython session

In [17]: matplotlib.__version__
Out[17]: '3.9.1'

In [18]: matplotlib.__version__ > '3.13.0'
Out[18]: True

In [19]: matplotlib.__version__ > '3.5.0'
Out[19]: True

It should be handle by a module such as packaging.version or importlib
@smoia

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,
reject,
"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,
insert,
"horizontal",
button=3,
useblit=True,
rectprops=dict(facecolor="green", alpha=0.3),
**{property_name: dict(facecolor='green', alpha=0.3)},
)

self.plot_signals(False)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading