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

New clear() method for Radio and Check buttons #13401

Merged

Conversation

raamana
Copy link
Contributor

@raamana raamana commented Feb 10, 2019

PR Summary

Continuing #10924 to clear up some merge/rebase issues and have a fresh start

Fixes #10922

cc @jklymak

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
@jklymak
Copy link
Member

jklymak commented Feb 10, 2019

Ha, I was just trying to get it moving again - I'm not actually familiar enough with the Radio Button stuff to review it.

@raamana
Copy link
Contributor Author

raamana commented Feb 10, 2019

Hi @jklymak, it was ALL approved in #10924 (3 approving reviews etc) except for waiting for the tests!! I hope we can merge this, so I can forget about it, and feel proud about having contributed to mighty matplotlib :)

@jklymak
Copy link
Member

jklymak commented Feb 10, 2019

Hmmm, well, it was approved, but the tests never passed, hence it never was merged. Its still not passing the tests so its still not going to be merged. People often approve PRs assuming that the tests will catch anything unforeseen. In this case, they appear to have, so you will have to pass that hurdle first.

@raamana
Copy link
Contributor Author

raamana commented Feb 10, 2019

I see. What do the tests in Azure pipeline test?
https://dev.azure.com/matplotlib/matplotlib/_build/results?buildId=1835&view=ms.vss-test-web.build-test-results-tab

what about this one from travis - no language set - are they not the same tests?
https://travis-ci.org/matplotlib/matplotlib/jobs/491327354

@raamana
Copy link
Contributor Author

raamana commented Feb 10, 2019

Also, all the errors seem to be with backed, which my code has NOTHING to do with - see https://travis-ci.org/matplotlib/matplotlib/jobs/491327353

=================================== FAILURES ===================================
___________________ lib/matplotlib/tests/test_backend_qt.py ____________________
[gw0] linux -- Python 3.7.1 /home/travis/virtualenv/python3.7.1/bin/python
Worker 'gw0' crashed while running 'lib/matplotlib/tests/test_backend_qt.py::test_fig_close[Qt5Agg]'
___________________ lib/matplotlib/tests/test_backend_qt.py ____________________
[gw1] linux -- Python 3.7.1 /home/travis/virtualenv/python3.7.1/bin/python
Worker 'gw1' crashed while running 'lib/matplotlib/tests/test_backend_qt.py::test_fig_signals'
___________________ lib/matplotlib/tests/test_backend_qt.py ____________________
[gw3] linux -- Python 3.7.1 /home/travis/virtualenv/python3.7.1/bin/python
Worker 'gw3' crashed while running 'lib/matplotlib/tests/test_backend_qt.py::test_correct_key[Qt5Agg-shift]'
___________________ lib/matplotlib/tests/test_backend_qt.py ____________________
[gw4] linux -- Python 3.7.1 /home/travis/virtualenv/python3.7.1/bin/python
Worker 'gw4' crashed while running 'lib/matplotlib/tests/test_backend_qt.py::test_correct_key[Qt5Agg-control]'
___________________ lib/matplotlib/tests/test_backend_qt.py ____________________
[gw2] linux -- Python 3.7.1 /home/travis/virtualenv/python3.7.1/bin/python
Worker 'gw2' crashed while running 'lib/matplotlib/tests/test_backend_qt.py::test_correct_key[Qt5Agg-lower]'
___________________ lib/matplotlib/tests/test_backend_qt.py ____________________
[gw5] linux -- Python 3.7.1 /home/travis/virtualenv/python3.7.1/bin/python
Worker 'gw5' crashed while running 'lib/matplotlib/tests/test_backend_qt.py::test_correct_key[Qt5Agg-unicode_lower]'
___________________ lib/matplotlib/tests/test_backend_qt.py ____________________
[gw7] linux -- Python 3.7.1 /home/travis/virtualenv/python3.7.1/bin/python
Worker 'gw7' crashed while running 'lib/matplotlib/tests/test_backend_qt.py::test_correct_key[Qt5Agg-control_alt]'
___________________ lib/matplotlib/tests/test_backend_qt.py ____________________
[gw8] linux -- Python 3.7.1 /home/travis/virtualenv/python3.7.1/bin/python
Worker 'gw8' crashed while running 'lib/matplotlib/tests/test_backend_qt.py::test_correct_key[Qt5Agg-unicode_upper]'
___________________ lib/matplotlib/tests/test_backend_qt.py ____________________
[gw9] linux -- Python 3.7.1 /home/travis/virtualenv/python3.7.1/bin/python
Worker 'gw9' crashed while running 'lib/matplotlib/tests/test_backend_qt.py::test_correct_key[Qt5Agg-backspace]'
_______________________ test_interactive_backend[qt5agg] _______________________
[gw6] linux -- Python 3.7.1 /home/travis/virtualenv/python3.7.1/bin/python
backend = 'qt5agg'

@raamana
Copy link
Contributor Author

raamana commented Feb 10, 2019

So when I run the tests locally, this time ensuring there is a DISPLAY via the VNC session, most of the test failures are gone. All the errors in the interactive backend are gone (esp the webagg, which I can't imagine why it would fail due to my code changes). What is left is one test in backend_pgf whatever that is!

test_backend_bases.py ........                                                                                                                                                                              [  7%]
test_backend_cairo.py s                                                                                                                                                                                     [  8%]
test_backend_nbagg.py .                                                                                                                                                                                     [  9%]
test_backend_pdf.py s............sssss.                                                                                                                                                                     [ 26%]
test_backend_pgf.py ssssssFss                                                                                                                                                                               [ 34%]
test_backend_ps.py .ss..s.s..sss                                                                                                                                                                            [ 46%]
test_backend_qt.py s..sssssssssss..............                                                                                                                                                             [ 72%]
test_backends_interactive.py ss.s.ss.                                                                                                                                                                       [ 79%]
test_backend_svg.py .s.ss.ss.ss                                                                                                                                                                             [ 89%]
test_backend_tools.py ...........  

@jklymak
Copy link
Member

jklymak commented Feb 10, 2019

Looks like the qt5 errors are unrelated.

@raamana
Copy link
Contributor Author

raamana commented Feb 10, 2019

So the two errors remaining are to do with rcparams and LaTeX - see below. I think I will quit at this point and leave it to you guys to figure the errors out - I don't have anymore time for this right now unless it's something to do with code changes I made (or DIRECTLY related to it).

E           ValueError: The following params are missing in the matplotlibrc.template file: dict_items([('boxplot.flierprops.markeredgewidth', [1.0, <function validate_float at 0x7f24739522f0>]), ('scatter.edgecolors', ['face', <function validate_string at 0x7f2473952f28>])])

test_rcparams.py:464:
E           matplotlib.backends.backend_pgf.LatexError: LaTeX returned an error, probably missing font or error in preamble:
E           b'This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)\n %&-line parsing enabled.\n**entering extended mode\n\n*! I can\'t find file `".ogut"\'.\n<to be read again> \n                   \\let \n<*> \\documentclass\n                  {minimal}\n(Press Enter to retry, or Control-D to exit)\nPlease type another input file name: ! I can\'t find file `".ogut"\'.\n<to be read again> \n                   \\let \n<*> \\documentclass\n                  {minimal}\n(Press Enter to retry, or Control-D to exit)\nPlease type another input file name: ! I can\'t find file `".ogut"\'.\n<to be read again> \n                   \\let \n<*> \\documentclass\n                  {minimal}\n(Press Enter to retry, or Control-D to exit)\nPlease type another input file name: ! I can\'t find file `\\begin{document}\'.\n<to be read again> \n                   \\let \n<*> \\documentclass\n                  {minimal}\n(Press Enter to retry, or Control-D to exit)\nPlease type another input file name: ! I can\'t find file `text\'.\n<to be read again> \n                   \\let \n<*> \\documentclass\n                  {minimal}\n(Press Enter to retry, or Control-D to exit)\nPlease type another input file name: ! I can\'t find file `\\typeout{pgf_backend_query_start}\'.\n<to be read again> \n                   \\let \n<*> \\documentclass\n                  {minimal}\n(Press Enter to retry, or Control-D to exit)\nPlease type another input file name: ! I can\'t find file `\\makeatletter\'.\n<to be read again> \n                   \\let \n<*> \\documentclass\n                  {minimal}\n(Press Enter to retry, or Control-D to exit)\nPlease type another input file name: ! I can\'t find file `\\@@end\'.\n<to be read again> \n                   \\let \n<*> \\documentclass\n                  {minimal}\n(Press Enter to retry, or Control-D to exit)\nPlease type another input file name: \n! Emergency stop.\n<to be read again> \n                   \\let \n<*> \\documentclass\n                  {minimal}\n!  ==> Fatal error occurred, no output PDF file produced!\nTranscript written on texput.log.\n'

../backends/backend_pgf.py:308: LatexError
---------------------------------------------------------------------------------------------- Captured stdout call -----------------------------------------------------------------------------------------------
This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6)
 %&-line parsing enabled.
**entering extended mode

*! I can't find file `".ogut"'.
<to be read again> 
                   \let 
<*> \documentclass
                  {minimal}
(Press Enter to retry, or Control-D to exit)
Please type another input file name: ! I can't find file `".ogut"'.
<to be read again> 
                   \let 
<*> \documentclass
                  {minimal}
(Press Enter to retry, or Control-D to exit)
Please type another input file name: ! I can't find file `".ogut"'.
<to be read again> 
                   \let 
<*> \documentclass
                  {minimal}
(Press Enter to retry, or Control-D to exit)
Please type another input file name: ! I can't find file `\begin{document}'.
<to be read again> 
                   \let 
<*> \documentclass
                  {minimal}
(Press Enter to retry, or Control-D to exit)
Please type another input file name: ! I can't find file `text'.
<to be read again> 
                   \let 
<*> \documentclass
                  {minimal}
(Press Enter to retry, or Control-D to exit)
Please type another input file name: ! I can't find file `\typeout{pgf_backend_query_start}'.
<to be read again> 
                   \let 
<*> \documentclass
                  {minimal}
(Press Enter to retry, or Control-D to exit)
Please type another input file name: ! I can't find file `\makeatletter'.
<to be read again> 
                   \let 
<*> \documentclass
                  {minimal}
(Press Enter to retry, or Control-D to exit)
Please type another input file name: ! I can't find file `\@@end'.
<to be read again> 
                   \let 
<*> \documentclass
                  {minimal}
(Press Enter to retry, or Control-D to exit)
Please type another input file name: 
! Emergency stop.
<to be read again> 
                   \let 
<*> \documentclass
                  {minimal}
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on texput.log.

@raamana
Copy link
Contributor Author

raamana commented Feb 13, 2019

Yes @jklymak, these errors seem to be unrelated to my work. What's the process for accepting PRs in a situation like this here?

@jklymak
Copy link
Member

jklymak commented Feb 13, 2019

I'll try recycling...

@jklymak jklymak closed this Feb 13, 2019
@jklymak jklymak reopened this Feb 13, 2019
@anntzer
Copy link
Contributor

anntzer commented Feb 13, 2019

Some (real, this-PR-related) style issues: https://travis-ci.org/matplotlib/matplotlib/jobs/492794388.

@raamana
Copy link
Contributor Author

raamana commented Feb 13, 2019

thanks - fixed the two flake issues:

(py36) $ 13:28:22 SQuark-3 matplotlib >>  flake8 --statistics widgets.py
(py36) $ 13:28:35 SQuark-3 matplotlib >>

@raamana
Copy link
Contributor Author

raamana commented Feb 13, 2019

Lovely - great to see it all green here :)

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Please follow numpydoc-style and PEP-257 docstring conventions.

lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
@raamana
Copy link
Contributor Author

raamana commented Feb 14, 2019

Style comments are addressed.

@raamana
Copy link
Contributor Author

raamana commented Feb 14, 2019

Ok, I think I am done. This has been a great learning exercise trying to contribute to a complex OS library :). I totally severely underestimated what it takes :)

@raamana
Copy link
Contributor Author

raamana commented Feb 14, 2019

This also closes #10924

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Sorry, still some changes needed. But you're getting there.

lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
@raamana
Copy link
Contributor Author

raamana commented Feb 14, 2019

Thanks Tim for detailed review and comments.

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Please make sure that the PR is ready for review to the best of your knowledge and then leave a comment.

Reviewing is a time consuming activity and reviewer time is better spend than finding and commenting on formal and formatting issues. I expect from a PR author to put reasonable care into the PR.

Sorry for being a bit harsh. It's not personal. You are a new contributor, so it's clear that the PR will take more effort, but we're dancing around this single PR for quite some time, and we have a backlog of 270 open PRs in the project.

lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
@QuLogic QuLogic force-pushed the new_clear_method_radio_check_buttons branch 2 times, most recently from 67ac54f to afed741 Compare May 10, 2023 04:17
@QuLogic QuLogic force-pushed the new_clear_method_radio_check_buttons branch from afed741 to c4001e5 Compare May 10, 2023 04:24
@QuLogic
Copy link
Member

QuLogic commented May 10, 2023

I rebased, cleaned up the conflicts, and squashed to one commit. The clear method on RadioButtons does allow setting no buttons selected, which is something that's no longer allowed in __init__: 3c306a3#r106438132

I wonder if instead, we want to remember the initial active index set in __init__ and make clear reset to that?

@QuLogic QuLogic marked this pull request as ready for review May 10, 2023 04:47
@jklymak jklymak requested a review from timhoffm June 13, 2023 15:25
@jklymak
Copy link
Member

jklymak commented Jun 13, 2023

I think I agree that radio buttons should always have at least one element selected. If you need a "none of the above", then that should be another button choice. https://uxplanet.org/radio-buttons-ux-design-588e5c0a50dc

@jklymak jklymak marked this pull request as draft July 6, 2023 16:30
@jklymak
Copy link
Member

jklymak commented Jul 6, 2023

I'll move to draft

@QuLogic QuLogic force-pushed the new_clear_method_radio_check_buttons branch 2 times, most recently from dcd02b2 to ef00c97 Compare July 6, 2023 19:48
@QuLogic
Copy link
Member

QuLogic commented Jul 6, 2023

OK, RadioButtons.clear now resets back to the original setup.

@QuLogic QuLogic marked this pull request as ready for review July 6, 2023 19:48
@QuLogic QuLogic force-pushed the new_clear_method_radio_check_buttons branch from ef00c97 to bf16ff0 Compare August 1, 2023 07:27
Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

This needs a what's new entry.

lib/matplotlib/tests/test_widgets.py Outdated Show resolved Hide resolved
@@ -1844,11 +1901,28 @@ def set_active(self, index):
if self.eventson:
self._observers.process('clicked', self.labels[index].get_text())

def clear(self):
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering whether this should be named reset().

Pro reset: This is the correct terminology. You cannot clear a radio button group.
Pro clear: Consistency with other widget. There are a number of widgets with clear methods, but none with reset.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it would probably make more sense, but I left it clear for consistency.

@QuLogic QuLogic force-pushed the new_clear_method_radio_check_buttons branch from bf16ff0 to 28116fa Compare August 2, 2023 01:24
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
@jklymak jklymak requested a review from timhoffm October 3, 2023 23:02
@timhoffm
Copy link
Member

timhoffm commented Oct 4, 2023

I’ll review later today, but this looks good.

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Minor docstring improvements.

lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
lib/matplotlib/widgets.py Outdated Show resolved Hide resolved
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
@QuLogic QuLogic force-pushed the new_clear_method_radio_check_buttons branch from a21e9b8 to eb6e233 Compare October 5, 2023 19:56
@timhoffm timhoffm added this to the v3.9.0 milestone Oct 5, 2023
@timhoffm timhoffm merged commit eece60a into matplotlib:main Oct 5, 2023
39 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

ENH: clear() method for widgets.RadioButtons
6 participants