-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PR: Add new "Plotting library" option, defaulting to Matplotlib (Variable Explorer) #20075
base: master
Are you sure you want to change the base?
PR: Add new "Plotting library" option, defaulting to Matplotlib (Variable Explorer) #20075
Conversation
(default: matplotlib)
… plotting windows)
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.
Hey @PierreRaybaut, thanks a lot your first contribution after a long time! This is my initial review for you.
def get_default_plotlib(): | ||
"""Return default plotting library""" | ||
names = get_available_plotlibs() | ||
if names is not None: | ||
return names[0] |
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.
This function returns None
if no library is available, which I think wouldn't look good in our Preferences. So, perhaps it should return Matplotlib
?
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.
Actually that's not a problem because if there is no library available, the combo box won't be displayed in Preferences: combo box is added to Preferences page only if plotlib.AVAILABLE_PLOTLIBS
is not empty. But I realize that it's not a good idea because even if plotlib.AVAILABLE_PLOTLIBS
is empty, that does not mean that the IPython kernel won't have the library installed. So I'm rolling back on this.
And there is another problem: I've just did some tests and apparently Spyder Preferences do not handle well dynamic choices in combo boxes: if the choices are not the same as the previous run, the displayed choice in Preferences page will be changed but won't be considered as a new value when validating the dialog box. In other words, in that last case and if the list of choices is reduced to a single choice, it won't be possible to select the one and only choice available by validating the Preferences page...
So, I'm rolling back and proposing a static list for plotting libraries in the Preferences page. This should have some impact on other modules. I'll see about that.
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.
See 7adeece
|
||
# Defining compatible plotting libraries | ||
# (default library is the first available, see `get_default_plotlib`) | ||
LIBRARIES = ("matplotlib", "guiqwt") |
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 think these names should be capitalized to look good in our Preferences. What do you think?
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.
Both library logos display their names in all lowercase, so I would suggest not bothering with capitalizing them, hence simplifying code (key == value, as for the combo box management).
spyder/widgets/collectionseditor.py
Outdated
QMessageBox.critical(self, _( "Plot"), | ||
_("<b>Unable to plot data.</b>" | ||
"<br><br>Error message:<br>%s" | ||
) % str(error)) |
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.
QMessageBox.critical(self, _( "Plot"), | |
_("<b>Unable to plot data.</b>" | |
"<br><br>Error message:<br>%s" | |
) % str(error)) | |
QMessageBox.critical( | |
self, | |
_( "Plot"), | |
_("<b>Unable to plot data.</b><br><br>" | |
"The error message was:<br>%s") % str(error) | |
) |
Improve formatting and message a bit.
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.
Regarding code formatting, you really should consider using Black and force everyone contributing to do so. At work, all my teams are using Black together with isort with proper configuration (I gradually imposed this on all projects since 2018). CodraFT is an example of project following standard guidelines in terms of code quality.
Using (and forcing all contributors to use) Black saves time, increases code quality and helps focusing on real code changes (instead of being annoyed with code appearance).
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.
Should I push this further? (by integrating Black into Spyder for example?)
Note: I'm marking this for Spyder 6 because it requires changes both in the kernel and Spyder to work. Those kind of changes are released on minor or major versions (e.g. 5.5.0 or 6.0.0), but the core team decided that we're not going to have more minor versions to try to release Spyder 6 sooner. |
Improve formatting and message a bit Co-authored-by: Carlos Cordoba <ccordoba12@gmail.com>
Improve formatting and message a bit Co-authored-by: Carlos Cordoba <ccordoba12@gmail.com>
Improve formatting and message a bit Co-authored-by: Carlos Cordoba <ccordoba12@gmail.com>
Co-authored-by: Carlos Cordoba <ccordoba12@gmail.com>
…nels.git --branch=improving_guiqwt_integration_kernel --update --force external-deps/spyder-kernels subrepo: subdir: "external-deps/spyder-kernels" merged: "6c5418b28" upstream: origin: "https://github.com/PierreRaybaut/spyder-kernels.git" branch: "improving_guiqwt_integration_kernel" commit: "6c5418b28" git-subrepo: version: "0.4.5" origin: "???" commit: "???"
Description of Changes
Added new option "Plotting library" to Variable Explorer plugin:
This allows to choose one of the compatible libraries (currently: matplotlib or guiqwt) for plotting data from the Variable Explorer. Until this PR, default plotting library was guiqwt (if installed) or matplotlib (if guiqwt was not found). This option works for the %varexp magic command (i.e. within currently running IPython kernel) and for nested arrays (i.e. within Spyder main process).
Affirmation
By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.
I certify the above statement is true and correct: