Hello community,
here is the log from the commit of package python-mplcursors for
openSUSE:Factory checked in at 2020-07-24 09:57:55
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-mplcursors (Old)
and /work/SRC/openSUSE:Factory/.python-mplcursors.new.3592 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-mplcursors"
Fri Jul 24 09:57:55 2020 rev:4 rq:822354 version:0.3
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-mplcursors/python-mplcursors.changes
2020-06-10 00:49:39.419139749 +0200
+++
/work/SRC/openSUSE:Factory/.python-mplcursors.new.3592/python-mplcursors.changes
2020-07-24 09:59:32.421619803 +0200
@@ -1,0 +2,18 @@
+Thu Jul 23 09:54:39 UTC 2020 - Benjamin Greiner <[email protected]>
+
+- moved Pillow requirement to matplotlib package
+
+-------------------------------------------------------------------
+Tue Jul 21 22:23:22 UTC 2020 - Benjamin Greiner <[email protected]>
+
+- allow newest pytest again
+- require Pillow
+- apply upstream patches to allow newest matplotlib and numpy
+ gh#anntzer/mplcursors#26
+ * mplcursors-unicodeminus.patch
+ * mplcursors-newstem.patch
+ * mplcursors-parse_annotation.patch
+ * mplcursors-fix-LineCollection.patch
+ * mplcursors-unicodeminus2.patch
+
+-------------------------------------------------------------------
New:
----
mplcursors-fix-LineCollection.patch
mplcursors-newstem.patch
mplcursors-parse_annotation.patch
mplcursors-unicodeminus.patch
mplcursors-unicodeminus2.patch
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-mplcursors.spec ++++++
--- /var/tmp/diff_new_pack.Ew3Bmc/_old 2020-07-24 09:59:33.161620492 +0200
+++ /var/tmp/diff_new_pack.Ew3Bmc/_new 2020-07-24 09:59:33.165620496 +0200
@@ -25,6 +25,12 @@
License: MIT
URL: https://github.com/anntzer/mplcursors
Source:
https://files.pythonhosted.org/packages/source/m/mplcursors/mplcursors-%{version}.tar.gz
+# PATCH-FIX-UPSTREAM gh#anntzer/mplcursors#26
+Patch0: mplcursors-unicodeminus.patch
+Patch1: mplcursors-newstem.patch
+Patch2: mplcursors-parse_annotation.patch
+Patch3: mplcursors-fix-LineCollection.patch
+Patch4: mplcursors-unicodeminus2.patch
BuildRequires: %{python_module setuptools_scm}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
@@ -33,7 +39,7 @@
BuildArch: noarch
# SECTION test requirements
BuildRequires: %{python_module matplotlib >= 2.1}
-BuildRequires: %{python_module pytest < 5}
+BuildRequires: %{python_module pytest}
# /SECTION
%python_subpackages
@@ -42,6 +48,7 @@
%prep
%setup -q -n mplcursors-%{version}
+%autopatch -p1
%build
%python_build
@@ -56,6 +63,8 @@
%files %{python_files}
%doc CHANGELOG.rst README.rst
%license LICENSE.txt
-%{python_sitelib}/*
+%{python_sitelib}/mplcursors
+%{python_sitelib}/mplcursors.pth
+%{python_sitelib}/mplcursors-%{version}-py*.egg-info
%changelog
++++++ mplcursors-fix-LineCollection.patch ++++++
>From 1913149cceb0275f6b8f8bf7ad6e49ab61f5d736 Mon Sep 17 00:00:00 2001
From: Antony Lee <[email protected]>
Date: Thu, 30 Apr 2020 20:14:43 +0200
Subject: [PATCH] Don't use Matplotlib's incorrect LineCollection contains()
check.
---
lib/mplcursors/_pick_info.py | 32 ++++++++++++++++----------------
tests/test_mplcursors.py | 3 ++-
2 files changed, 18 insertions(+), 17 deletions(-)
Index: mplcursors-0.3/lib/mplcursors/_pick_info.py
===================================================================
--- mplcursors-0.3.orig/lib/mplcursors/_pick_info.py
+++ mplcursors-0.3/lib/mplcursors/_pick_info.py
@@ -332,13 +332,15 @@ def _(artist, event):
@compute_pick.register(PatchCollection)
@compute_pick.register(PathCollection)
def _(artist, event):
- # Use the C implementation to prune the list of segments.
- contains, info = artist.contains(event)
- if not contains:
- return
offsets = artist.get_offsets()
paths = artist.get_paths()
if _is_scatter(artist):
+ # Use the C implementation to prune the list of segments -- but only
+ # for scatter plots as that implementation is inconsistent with Line2D
+ # for segment-like collections (matplotlib/matplotlib#17279).
+ contains, info = artist.contains(event)
+ if not contains:
+ return
inds = info["ind"]
offsets = artist.get_offsets()[inds]
offsets_screen = artist.get_offset_transform().transform(offsets)
@@ -350,23 +352,21 @@ def _(artist, event):
return Selection(artist, target, ds[argmin], None, None)
else:
# Note that this won't select implicitly closed paths.
- sels = [
+ sels = [*filter(None, [
_compute_projection_pick(
artist,
Affine2D().translate(*offsets[ind % len(offsets)])
.transform_path(paths[ind % len(paths)]),
(event.x, event.y))
- for ind in info["ind"]]
- sel, index = min(
- ((sel, info["ind"][idx]) for idx, sel in enumerate(sels) if sel),
- key=lambda sel_idx: sel_idx[0].dist,
- default=(None, None))
- if sel:
- sel = sel._replace(artist=artist)
- sel.target.index = (index, sel.target.index)
- if (isinstance(artist, PatchCollection)
- and sel.dist >= PATCH_PICKRADIUS):
- sel = None
+ for ind in range(max(len(offsets), len(paths)))])]
+ if not sels:
+ return None
+ idx = min(range(len(sels)), key=lambda idx: sels[idx].dist)
+ sel = sels[idx]
+ if sel.dist >= artist.get_pickradius():
+ return None
+ sel = sel._replace(artist=artist)
+ sel.target.index = (idx, sel.target.index)
return sel
Index: mplcursors-0.3/tests/test_mplcursors.py
===================================================================
--- mplcursors-0.3.orig/tests/test_mplcursors.py
+++ mplcursors-0.3/tests/test_mplcursors.py
@@ -316,7 +316,8 @@ def test_image_subclass(ax):
def test_linecollection(ax):
ax.eventplot([0, 1])
cursor = mplcursors.cursor()
- _process_event("__mouse_click__", ax, (0, .5), 1)
+ _process_event("__mouse_click__", ax, (0, 0), 1)
+ _process_event("__mouse_click__", ax, (.5, 1), 1)
assert len(cursor.selections) == 0
_process_event("__mouse_click__", ax, (0, 1), 1)
assert cursor.selections[0].target.index == approx((0, .5))
++++++ mplcursors-newstem.patch ++++++
>From 6dbf40796b9774ae988fc650596880d31cbc0e89 Mon Sep 17 00:00:00 2001
From: Antony Lee <[email protected]>
Date: Thu, 16 Apr 2020 13:01:50 +0200
Subject: [PATCH] Switch to supporting new-style stem plots.
---
CHANGELOG.rst | 5 +++--
lib/mplcursors/_pick_info.py | 20 +++++++++++---------
tests/test_mplcursors.py | 2 +-
3 files changed, 15 insertions(+), 12 deletions(-)
Index: mplcursors-0.3/CHANGELOG.rst
===================================================================
--- mplcursors-0.3.orig/CHANGELOG.rst
+++ mplcursors-0.3/CHANGELOG.rst
@@ -1,3 +1,7 @@
+Patches
+======
+- Switch to supporting only "new-style" (`LineCollection`) `stem` plots.
+
0.3
===
@@ -39,8 +43,8 @@ Miscellaneous bugfixes.
- Selections on images now have an index as well.
- Selections created on `scatter` plots, `errorbar` plots, and `polar` plots
can now be moved.
-- `PathCollection`\s not created by `plt.scatter` are now picked as paths, not
- as collections of points.
+- `PathCollection`\s not created by `scatter` are now picked as paths, not as
+ collections of points.
- `Patch`\es now pick on their borders, not their interior.
- Improved picking of `Container`\s.
- In hover mode, annotations can still be removed by right-clicking.
Index: mplcursors-0.3/lib/mplcursors/_pick_info.py
===================================================================
--- mplcursors-0.3.orig/lib/mplcursors/_pick_info.py
+++ mplcursors-0.3/lib/mplcursors/_pick_info.py
@@ -464,14 +464,16 @@ def _(container, event):
sel = compute_pick(container.markerline, event)
if sel:
return sel
- idx_sel = min(filter(lambda idx_sel: idx_sel[1] is not None,
- ((idx, compute_pick(line, event))
- for idx, line in enumerate(container.stemlines))),
- key=lambda idx_sel: idx_sel[1].dist, default=None)
- if idx_sel:
- idx, _ = idx_sel
+ if not isinstance(container.stemlines, LineCollection):
+ warnings.warn("Only stem plots created with use_line_collection=True "
+ "are supported.")
+ return
+ sel = compute_pick(container.stemlines, event)
+ if sel:
+ idx, _ = sel.target.index
target = _with_attrs(
- container.stemlines[idx].get_xydata()[-1], index=idx)
+ container.stemlines.get_segments()[idx][-1],
+ index=sel.target.index)
return Selection(container, target, 0, None, None)
@@ -520,7 +522,7 @@ def get_ann_text(sel):
classes follow.
"""
warnings.warn(
- f"Annotation support for {type(sel.artist).__name__} is missing")
+ f"Annotation support for {type(sel.artist).__name__} is missing.")
return ""
@@ -753,7 +755,7 @@ def make_highlight(sel, *, highlight_kwa
classes follow.
"""
warnings.warn(
- f"Highlight support for {type(sel.artist).__name__} is missing")
+ f"Highlight support for {type(sel.artist).__name__} is missing.")
def _set_valid_props(artist, kwargs):
Index: mplcursors-0.3/tests/test_mplcursors.py
===================================================================
--- mplcursors-0.3.orig/tests/test_mplcursors.py
+++ mplcursors-0.3/tests/test_mplcursors.py
@@ -384,7 +384,7 @@ def test_dataless_errorbar(ax):
def test_stem(ax):
with pytest.warns(None): # stem use_line_collection API change.
- ax.stem([1, 2, 3])
+ ax.stem([1, 2, 3], use_line_collection=True)
cursor = mplcursors.cursor()
assert len(cursor.artists) == 1
_process_event("__mouse_click__", ax, (.5, .5), 1)
++++++ mplcursors-parse_annotation.patch ++++++
>From ef2a5a5e81c1a6dfd9c253032f003c45aec39431 Mon Sep 17 00:00:00 2001
From: Antony Lee <[email protected]>
Date: Thu, 16 Apr 2020 13:28:23 +0200
Subject: [PATCH] More _parse_annotations in tests given change in mpl's value
formatting.
---
tests/test_mplcursors.py | 49 ++++++++++++++++++++++------------------
1 file changed, 27 insertions(+), 22 deletions(-)
diff --git a/tests/test_mplcursors.py b/tests/test_mplcursors.py
index 3ccbfcf..e2b9678 100644
--- a/tests/test_mplcursors.py
+++ b/tests/test_mplcursors.py
@@ -124,8 +124,8 @@ def test_line(ax, plotter):
# On the line.
_process_event("__mouse_click__", ax, (.1, .4), 1)
assert len(cursor.selections) == len(ax.texts) == 1
- assert (_parse_annotation(cursor.selections[0], "foo\nx=(.*)\ny=(.*)")
- == approx((.1, .4)))
+ assert _parse_annotation(
+ cursor.selections[0], "foo\nx=(.*)\ny=(.*)") == approx((.1, .4))
# Not removing it.
_process_event("__mouse_click__", ax, (0, 1), 3)
assert len(cursor.selections) == len(ax.texts) == 1
@@ -133,8 +133,8 @@ def test_line(ax, plotter):
artist.set_label(None)
_process_event("__mouse_click__", ax, (.6, .9), 1)
assert len(cursor.selections) == len(ax.texts) == 2
- assert (_parse_annotation(cursor.selections[1], "x=(.*)\ny=(.*)")
- == approx((.6, .9)))
+ assert _parse_annotation(
+ cursor.selections[1], "x=(.*)\ny=(.*)") == approx((.6, .9))
# Remove both of them (first removing the second one, to test
# `Selection.__eq__` -- otherwise it is bypassed as `list.remove`
# checks identity first).
@@ -163,7 +163,8 @@ def test_scatter_text(ax):
ax.scatter([0, 1], [0, 1], c=[2, 3])
cursor = mplcursors.cursor()
_process_event("__mouse_click__", ax, (0, 0), 1)
- assert cursor.selections[0].annotation.get_text() == "x=0\ny=0\n[2]"
+ assert _parse_annotation(
+ cursor.selections[0], "x=(.*)\ny=(.*)\n\[(.*)\]") == (0, 0, 2)
def test_steps_index():
@@ -260,25 +261,25 @@ def test_image(ax, origin):
# Annotation text includes image value.
_process_event("__mouse_click__", ax, (.25, .25), 1)
sel, = cursor.selections
- assert (_parse_annotation(sel, r"x=(.*)\ny=(.*)\n\[0\]")
- == approx((.25, .25)))
+ assert _parse_annotation(
+ sel, r"x=(.*)\ny=(.*)\n\[0\]") == approx((.25, .25))
# Moving around.
_process_event("key_press_event", ax, (.123, .456), "shift+right")
sel, = cursor.selections
- assert sel.annotation.get_text() == "x=1\ny=0\n[1]"
+ assert _parse_annotation(sel, r"x=(.*)\ny=(.*)\n\[1\]") == (1, 0)
assert array[sel.target.index] == 1
_process_event("key_press_event", ax, (.123, .456), "shift+right")
sel, = cursor.selections
- assert sel.annotation.get_text() == "x=0\ny=0\n[0]"
+ assert _parse_annotation(sel, r"x=(.*)\ny=(.*)\n\[0\]") == (0, 0)
assert array[sel.target.index] == 0
_process_event("key_press_event", ax, (.123, .456), "shift+up")
sel, = cursor.selections
- assert (sel.annotation.get_text()
- == {"upper": "x=0\ny=2\n[4]", "lower": "x=0\ny=1\n[2]"}[origin])
+ assert (_parse_annotation(sel, r"x=(.*)\ny=(.*)\n\[(.*)\]")
+ == {"upper": (0, 2, 4), "lower": (0, 1, 2)}[origin])
assert array[sel.target.index] == {"upper": 4, "lower": 2}[origin]
_process_event("key_press_event", ax, (.123, .456), "shift+down")
sel, = cursor.selections
- assert sel.annotation.get_text() == "x=0\ny=0\n[0]"
+ assert _parse_annotation(sel, r"x=(.*)\ny=(.*)\n\[0\]") == (0, 0)
assert array[sel.target.index] == 0
cursor = mplcursors.cursor()
@@ -295,12 +296,12 @@ def test_image_rgb(ax):
cursor = mplcursors.cursor()
_process_event("__mouse_click__", ax, (0, 0), 1)
sel, = cursor.selections
- assert (_parse_annotation(sel, r"x=(.*)\ny=(.*)\n\[0.1, 0.2, 0.3\]")
- == approx((0, 0)))
+ assert _parse_annotation(
+ sel, r"x=(.*)\ny=(.*)\n\[0.1, 0.2, 0.3\]") == approx((0, 0))
_process_event("key_press_event", ax, (.123, .456), "shift+right")
sel, = cursor.selections
- assert (_parse_annotation(sel, r"x=(.*)\ny=(.*)\n\[0.4, 0.5, 0.6\]")
- == approx((1, 0)))
+ assert _parse_annotation(
+ sel, r"x=(.*)\ny=(.*)\n\[0.4, 0.5, 0.6\]") == approx((1, 0))
def test_image_subclass(ax):
@@ -339,7 +340,8 @@ def test_quiver_and_barbs(ax, plotter):
_process_event("__mouse_click__", ax, (.5, 0), 1)
assert len(cursor.selections) == 0
_process_event("__mouse_click__", ax, (1, 0), 1)
- assert cursor.selections[0].annotation.get_text() == "x=1\ny=0\n(1, 1)"
+ assert _parse_annotation(
+ cursor.selections[0], r"x=(.*)\ny=(.*)\n\(1, 1\)") == (1, 0)
@pytest.mark.parametrize("plotter,order",
@@ -363,14 +365,17 @@ def test_errorbar(ax):
assert len(cursor.selections) == 0
_process_event("__mouse_click__", ax, (.5, .5), 1)
assert cursor.selections[0].target == approx((.5, .5))
- assert (_parse_annotation(cursor.selections[0], "x=(.*)\ny=(.*)")
- == approx((.5, .5)))
+ assert _parse_annotation(
+ cursor.selections[0], "x=(.*)\ny=(.*)") == approx((.5, .5))
_process_event("__mouse_click__", ax, (0, 1), 1)
assert cursor.selections[0].target == approx((0, 0))
- assert cursor.selections[0].annotation.get_text() == "x=0\ny=$0\\pm1$"
+ assert _parse_annotation(
+ cursor.selections[0], r"x=(.*)\ny=\$(.*)\\pm(.*)\$") == (0, 0, 1)
_process_event("__mouse_click__", ax, (1, 2), 1)
- assert cursor.selections[0].target == approx((1, 1))
- assert cursor.selections[0].annotation.get_text() == "x=1\ny=$1_{-1}^{+2}$"
+ sel, = cursor.selections
+ assert sel.target == approx((1, 1))
+ assert _parse_annotation(
+ sel, r"x=(.*)\ny=\$(.*)_\{(.*)\}\^\{(.*)\}\$") == (1, 1, -1, 2)
def test_dataless_errorbar(ax):
++++++ mplcursors-unicodeminus.patch ++++++
>From b12a791f6f8fc8a2b920e2ccb2d8ae2dae79dba0 Mon Sep 17 00:00:00 2001
From: Antony Lee <[email protected]>
Date: Mon, 20 Jan 2020 08:47:58 +0100
Subject: [PATCH] Fix against use of unicode minus in mpl3.2.
---
lib/mplcursors/_pick_info.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
Index: mplcursors-0.3/lib/mplcursors/_pick_info.py
===================================================================
--- mplcursors-0.3.orig/lib/mplcursors/_pick_info.py
+++ mplcursors-0.3/lib/mplcursors/_pick_info.py
@@ -632,10 +632,16 @@ def _(sel):
for e in err]
# We'd normally want to check err.sum() == 0, but that can run
# into fp inaccuracies.
- if len({s.lstrip("+-") for s in err_s}) == 1:
+ signs = "+-\N{MINUS SIGN}"
+ if len({s.lstrip(signs) for s in err_s}) == 1:
repl = rf"\1=$\2\\pm{err_s[1]}$\3"
else:
- err_s = [("+" if not s.startswith(("+", "-")) else "") + s
+ # Replacing unicode minus by ascii minus don't change the
+ # rendering as the string is mathtext, but allows keeping
+ # the same tests across Matplotlib versions that use
+ # unicode minus and those that don't.
+ err_s = [("+" if not s.startswith(tuple(signs)) else "")
+ + s.replace("\N{MINUS SIGN}", "-")
for s in err_s]
repl = r"\1=$\2_{%s}^{%s}$\3" % tuple(err_s)
ann_text = re.sub(f"({dir})=(.*)(\n?)", repl, ann_text)
++++++ mplcursors-unicodeminus2.patch ++++++
Index: mplcursors-0.3/tests/test_mplcursors.py
===================================================================
--- mplcursors-0.3.orig/tests/test_mplcursors.py
+++ mplcursors-0.3/tests/test_mplcursors.py
@@ -26,6 +26,7 @@ approx = functools.partial(pytest.approx
@pytest.fixture
def fig():
+ plt.rcParams["axes.unicode_minus"] = False
fig = plt.figure(1)
fig.canvas.callbacks.exception_handler = None
return fig