-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Convert axis limit units in Qt plot options widget #19677
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
Convert axis limit units in Qt plot options widget #19677
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping @matplotlib/developers
or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
Previously axis limits were converted to floats regardless of the actual value type in Qt backend's plot options widget. This commit makes datetime axis limits get converted to actual datetime values which are considerably easier to edit. Also, the methods used to convert the datetime values back have different names under PySide2 and PyQt. Previously the options widget was using the methods provided by PyQt only. We now support both Qt bindings. Re #19075
I don't use this widget, but this seems to be quite heavily leaning on special casing. Can you do something with the generic unit machinery? |
This was discussed in the issue (#19075) and to my understanding there was a weak consesus of doing it this way in the absence of general unconverter. I understand the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll approve despite not liking the hack. I know @dstansby has been thinking about unconverters....
|
||
|
||
@pytest.mark.backend('Qt5Agg', skip_on_importerror=True) | ||
def test_form_widget_get_with_date_field(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would merge this test with the one above to avoid paying twice for the setup of the widget.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
widget = _formlayout.FormWidget(form) | ||
widget.setup() | ||
values = widget.get() | ||
assert(values == [datetime(year=2021, month=3, day=11)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert
needs no parentheses (it's not a function).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. Thanks for the heads up!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just two minor nits
anyone can merge postci |
PR Summary
Qt backend's plot options widget converts axis limits to floats regardless of the actual data type. If the axes use e.g. datetime values, this makes editing the axis limits next to impossible.
This tries to solve the problem at least for datetime values by converting them to a proper type that can be shown in
QDateTime
widget. The solution is probably not ideal as discussed in the issue but at least it helps users that regularly use datetime X axis a lot.Resolves #19075
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).