Elffuss BraidHub

kikocis/auto-code-rover public

main · 12.5 KiBRawPermalink
1{
2 "task_id": "matplotlib__matplotlib-23913",
3 "setup_info": {
4 "repo_path": "/home/haifeng/projects/reverse-prompt/SWE-bench/testbed/matplotlib__matplotlib/setup_matplotlib__matplotlib__3.6",
5 "env_name": "setup_matplotlib__matplotlib__3.6",
6 "pre_install": [],
7 "install": "python -m pip install -e .",
8 "test_cmd": "pytest --no-header -rA --tb=no -p no:cacheprovider lib/matplotlib/tests/test_legend.py"
9 },
10 "task_info": {
11 "instance_id": "matplotlib__matplotlib-23913",
12 "base_commit": "5c4595267ccd3daf78f5fd05693b7ecbcd575c1e",
13 "hints_text": "This seems like a reasonable request, you're welcome to submit a PR :-) Note that the same comment applies to annotations.\r\nI would also deprecate `draggable()` in favor of the more classic `set_draggable()`, `get_draggable()` (and thus, in the long-term future, `.draggable` could become a property).",
14 "created_at": "2022-09-16T21:51:24Z",
15 "test_patch": "diff --git a/lib/matplotlib/tests/test_legend.py b/lib/matplotlib/tests/test_legend.py\n--- a/lib/matplotlib/tests/test_legend.py\n+++ b/lib/matplotlib/tests/test_legend.py\n@@ -783,6 +783,14 @@ def test_get_set_draggable():\n assert not legend.get_draggable()\n \n \n+@pytest.mark.parametrize('draggable', (True, False))\n+def test_legend_draggable(draggable):\n+ fig, ax = plt.subplots()\n+ ax.plot(range(10), label='shabnams')\n+ leg = ax.legend(draggable=draggable)\n+ assert leg.get_draggable() is draggable\n+\n+\n def test_alpha_handles():\n x, n, hh = plt.hist([1, 2, 3], alpha=0.25, label='data', color='red')\n legend = plt.legend()\n",
16 "repo": "matplotlib/matplotlib",
17 "problem_statement": "legend draggable as keyword\n<!--To help us understand and resolve your issue, please fill out the form to the best of your ability.-->\r\n<!--You can feel free to delete the sections that do not apply.-->\r\n\r\n### Feature request\r\n\r\n**There is not keyword to make legend draggable at creation**\r\n\r\n<!--A short 1-2 sentences that succinctly describes the bug-->\r\n\r\nIs there a code reason why one can not add a \"draggable=True\" keyword to the __init__ function for Legend? This would be more handy than having to call it after legend creation. And, naively, it would seem simple to do. But maybe there is a reason why it would not work?\n",
18 "version": "3.6",
19 "FAIL_TO_PASS": [
20 "lib/matplotlib/tests/test_legend.py::test_legend_draggable[False]",
21 "lib/matplotlib/tests/test_legend.py::test_legend_draggable[True]"
22 ],
23 "PASS_TO_PASS": [
24 "lib/matplotlib/tests/test_legend.py::TestLegendFigureFunction::test_legend_handle_label",
25 "lib/matplotlib/tests/test_legend.py::TestLegendFigureFunction::test_legend_kw_args",
26 "lib/matplotlib/tests/test_legend.py::TestLegendFigureFunction::test_legend_label_arg",
27 "lib/matplotlib/tests/test_legend.py::TestLegendFigureFunction::test_legend_label_three_args",
28 "lib/matplotlib/tests/test_legend.py::TestLegendFigureFunction::test_legend_label_three_args_pluskw",
29 "lib/matplotlib/tests/test_legend.py::TestLegendFigureFunction::test_legend_no_args",
30 "lib/matplotlib/tests/test_legend.py::TestLegendFigureFunction::test_warn_args_kwargs",
31 "lib/matplotlib/tests/test_legend.py::TestLegendFunction::test_legend_handler_map",
32 "lib/matplotlib/tests/test_legend.py::TestLegendFunction::test_legend_kwargs_handles_labels",
33 "lib/matplotlib/tests/test_legend.py::TestLegendFunction::test_legend_kwargs_handles_only",
34 "lib/matplotlib/tests/test_legend.py::TestLegendFunction::test_legend_kwargs_labels_only",
35 "lib/matplotlib/tests/test_legend.py::TestLegendFunction::test_legend_no_args",
36 "lib/matplotlib/tests/test_legend.py::TestLegendFunction::test_legend_positional_handles_labels",
37 "lib/matplotlib/tests/test_legend.py::TestLegendFunction::test_legend_positional_handles_only",
38 "lib/matplotlib/tests/test_legend.py::TestLegendFunction::test_legend_positional_labels_only",
39 "lib/matplotlib/tests/test_legend.py::TestLegendFunction::test_legend_three_args",
40 "lib/matplotlib/tests/test_legend.py::TestLegendFunction::test_parasite",
41 "lib/matplotlib/tests/test_legend.py::TestLegendFunction::test_warn_mixed_args_and_kwargs",
42 "lib/matplotlib/tests/test_legend.py::test_alpha_handles",
43 "lib/matplotlib/tests/test_legend.py::test_alpha_rcparam[png]",
44 "lib/matplotlib/tests/test_legend.py::test_alpha_rgba[png]",
45 "lib/matplotlib/tests/test_legend.py::test_cross_figure_patch_legend",
46 "lib/matplotlib/tests/test_legend.py::test_empty_bar_chart_with_legend",
47 "lib/matplotlib/tests/test_legend.py::test_fancy[pdf]",
48 "lib/matplotlib/tests/test_legend.py::test_fancy[png]",
49 "lib/matplotlib/tests/test_legend.py::test_framealpha[pdf]",
50 "lib/matplotlib/tests/test_legend.py::test_framealpha[png]",
51 "lib/matplotlib/tests/test_legend.py::test_get_set_draggable",
52 "lib/matplotlib/tests/test_legend.py::test_handler_numpoints",
53 "lib/matplotlib/tests/test_legend.py::test_handlerline2d",
54 "lib/matplotlib/tests/test_legend.py::test_hatching[pdf]",
55 "lib/matplotlib/tests/test_legend.py::test_hatching[png]",
56 "lib/matplotlib/tests/test_legend.py::test_labels_first[png]",
57 "lib/matplotlib/tests/test_legend.py::test_legend_alignment[center]",
58 "lib/matplotlib/tests/test_legend.py::test_legend_alignment[left]",
59 "lib/matplotlib/tests/test_legend.py::test_legend_alignment[right]",
60 "lib/matplotlib/tests/test_legend.py::test_legend_auto1[pdf]",
61 "lib/matplotlib/tests/test_legend.py::test_legend_auto1[png]",
62 "lib/matplotlib/tests/test_legend.py::test_legend_auto2[pdf]",
63 "lib/matplotlib/tests/test_legend.py::test_legend_auto2[png]",
64 "lib/matplotlib/tests/test_legend.py::test_legend_auto3[pdf]",
65 "lib/matplotlib/tests/test_legend.py::test_legend_auto3[png]",
66 "lib/matplotlib/tests/test_legend.py::test_legend_expand[pdf]",
67 "lib/matplotlib/tests/test_legend.py::test_legend_expand[png]",
68 "lib/matplotlib/tests/test_legend.py::test_legend_face_edgecolor",
69 "lib/matplotlib/tests/test_legend.py::test_legend_label_with_leading_underscore",
70 "lib/matplotlib/tests/test_legend.py::test_legend_labelcolor_linecolor",
71 "lib/matplotlib/tests/test_legend.py::test_legend_labelcolor_list",
72 "lib/matplotlib/tests/test_legend.py::test_legend_labelcolor_markeredgecolor",
73 "lib/matplotlib/tests/test_legend.py::test_legend_labelcolor_markerfacecolor",
74 "lib/matplotlib/tests/test_legend.py::test_legend_labelcolor_rcparam_linecolor",
75 "lib/matplotlib/tests/test_legend.py::test_legend_labelcolor_rcparam_markeredgecolor",
76 "lib/matplotlib/tests/test_legend.py::test_legend_labelcolor_rcparam_markeredgecolor_short",
77 "lib/matplotlib/tests/test_legend.py::test_legend_labelcolor_rcparam_markerfacecolor",
78 "lib/matplotlib/tests/test_legend.py::test_legend_labelcolor_rcparam_markerfacecolor_short",
79 "lib/matplotlib/tests/test_legend.py::test_legend_labelcolor_rcparam_single[color2]",
80 "lib/matplotlib/tests/test_legend.py::test_legend_labelcolor_rcparam_single[none]",
81 "lib/matplotlib/tests/test_legend.py::test_legend_labelcolor_rcparam_single[red]",
82 "lib/matplotlib/tests/test_legend.py::test_legend_labelcolor_single[color2]",
83 "lib/matplotlib/tests/test_legend.py::test_legend_labelcolor_single[none]",
84 "lib/matplotlib/tests/test_legend.py::test_legend_labelcolor_single[red]",
85 "lib/matplotlib/tests/test_legend.py::test_legend_markers_from_line2d",
86 "lib/matplotlib/tests/test_legend.py::test_legend_ordereddict",
87 "lib/matplotlib/tests/test_legend.py::test_legend_proper_window_extent",
88 "lib/matplotlib/tests/test_legend.py::test_legend_remove",
89 "lib/matplotlib/tests/test_legend.py::test_legend_repeatcheckok",
90 "lib/matplotlib/tests/test_legend.py::test_legend_set_alignment[center]",
91 "lib/matplotlib/tests/test_legend.py::test_legend_set_alignment[left]",
92 "lib/matplotlib/tests/test_legend.py::test_legend_set_alignment[right]",
93 "lib/matplotlib/tests/test_legend.py::test_legend_stackplot[png]",
94 "lib/matplotlib/tests/test_legend.py::test_legend_text_axes",
95 "lib/matplotlib/tests/test_legend.py::test_legend_title_empty",
96 "lib/matplotlib/tests/test_legend.py::test_legend_title_fontprop_fontsize",
97 "lib/matplotlib/tests/test_legend.py::test_linecollection_scaled_dashes",
98 "lib/matplotlib/tests/test_legend.py::test_multiple_keys[png]",
99 "lib/matplotlib/tests/test_legend.py::test_nanscatter",
100 "lib/matplotlib/tests/test_legend.py::test_ncol_ncols[pdf]",
101 "lib/matplotlib/tests/test_legend.py::test_ncol_ncols[png]",
102 "lib/matplotlib/tests/test_legend.py::test_no_warn_big_data_when_loc_specified",
103 "lib/matplotlib/tests/test_legend.py::test_not_covering_scatter[png]",
104 "lib/matplotlib/tests/test_legend.py::test_not_covering_scatter_transform[png]",
105 "lib/matplotlib/tests/test_legend.py::test_plot_multiple_input_multiple_label[label_array0]",
106 "lib/matplotlib/tests/test_legend.py::test_plot_multiple_input_multiple_label[label_array1]",
107 "lib/matplotlib/tests/test_legend.py::test_plot_multiple_input_multiple_label[label_array2]",
108 "lib/matplotlib/tests/test_legend.py::test_plot_multiple_input_single_label[1]",
109 "lib/matplotlib/tests/test_legend.py::test_plot_multiple_input_single_label[int]",
110 "lib/matplotlib/tests/test_legend.py::test_plot_multiple_input_single_label[one]",
111 "lib/matplotlib/tests/test_legend.py::test_plot_multiple_label_incorrect_length_exception",
112 "lib/matplotlib/tests/test_legend.py::test_plot_single_input_multiple_label[label_array0]",
113 "lib/matplotlib/tests/test_legend.py::test_plot_single_input_multiple_label[label_array1]",
114 "lib/matplotlib/tests/test_legend.py::test_plot_single_input_multiple_label[label_array2]",
115 "lib/matplotlib/tests/test_legend.py::test_rc[pdf]",
116 "lib/matplotlib/tests/test_legend.py::test_rc[png]",
117 "lib/matplotlib/tests/test_legend.py::test_setting_alpha_keeps_polycollection_color",
118 "lib/matplotlib/tests/test_legend.py::test_shadow_framealpha",
119 "lib/matplotlib/tests/test_legend.py::test_subfigure_legend",
120 "lib/matplotlib/tests/test_legend.py::test_text_nohandler_warning",
121 "lib/matplotlib/tests/test_legend.py::test_various_labels[pdf]",
122 "lib/matplotlib/tests/test_legend.py::test_various_labels[png]",
123 "lib/matplotlib/tests/test_legend.py::test_warn_big_data_best_loc",
124 "lib/matplotlib/tests/test_legend.py::test_window_extent_cached_renderer"
125 ],
126 "environment_setup_commit": "73909bcb408886a22e2b84581d6b9e6d9907c813",
127 "patch": "diff --git a/lib/matplotlib/legend.py b/lib/matplotlib/legend.py\n--- a/lib/matplotlib/legend.py\n+++ b/lib/matplotlib/legend.py\n@@ -286,6 +286,9 @@ def _update_bbox_to_anchor(self, loc_in_canvas):\n The custom dictionary mapping instances or types to a legend\n handler. This *handler_map* updates the default handler map\n found at `matplotlib.legend.Legend.get_legend_handler_map`.\n+\n+draggable : bool, default: False\n+ Whether the legend can be dragged with the mouse.\n \"\"\")\n \n \n@@ -342,7 +345,8 @@ def __init__(\n title_fontproperties=None, # properties for the legend title\n alignment=\"center\", # control the alignment within the legend box\n *,\n- ncol=1 # synonym for ncols (backward compatibility)\n+ ncol=1, # synonym for ncols (backward compatibility)\n+ draggable=False # whether the legend can be dragged with the mouse\n ):\n \"\"\"\n Parameters\n@@ -537,7 +541,9 @@ def val_or_rc(val, rc_name):\n title_prop_fp.set_size(title_fontsize)\n \n self.set_title(title, prop=title_prop_fp)\n+\n self._draggable = None\n+ self.set_draggable(state=draggable)\n \n # set the text color\n \n",
128 "pr_link": "https://github.com/matplotlib/matplotlib/pull/23913"
129 }
130}