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
Organize arguments of functions and apply colorblind_safe option #2170
Conversation
I combined spin distribution functions for 2d and 3d into one. Those two will be deleted. |
I added new_hinton. The arguments in new_hinton are more organized than those in hinton. It will replace hinton. |
@Ericgig Hi. I changed hinton, matrix_histogram_complex, and plot_energy_level this weekend. Could you let me know if the selection of arguments is good? Thank you. Here is a sample use. |
Hi. I worked on |
I will work on |
Merge branch 'GSoC_project6_week1' of github.com:tamakoshi2001/qutip into GSoC_project6_week1
Other than doing the changes you suggested, I updated the description and deleted all deprecated functions. |
@Ericgig Hi. I have some questions about your suggestions above. Could you answer them? |
@Ericgig Hi. I made a few changes. |
@Ericgig Could you review the code? |
qutip/visualization.py
Outdated
try: | ||
x_basis, y_basis = _default_cb_labels(x_basis, y_basis, M) | ||
except Exception: | ||
pass |
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.
Why is there a try, except
clause here?
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.
That code makes bra and ket like labels by using dimensions of Qobj. If it does not exist, when users want to see superoperators, the code outputs an error because of their dimensions. I believe showing plot is more important than adding labels.
superoperator.pdf
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.
Dimensions exist for all Qobj including superoperators.
If _default_cb_labels
does not support superoperator, we could add that support or use
try: | |
x_basis, y_basis = _default_cb_labels(x_basis, y_basis, M) | |
except Exception: | |
pass | |
if not M.issuper: | |
x_basis, y_basis = _default_cb_labels(x_basis, y_basis, M) |
to make clear this is a special case.
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.
Hi. I do not know that dimensions exist for all Qobj. I used the shape of Qobj and the code should work for all Qobj now. I deleted _default_cb_labels because this is made to follow pep8 and we no longer need it.
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.
Look good, I will play with it a little more tomorrow before finishing the review.
…default_cb_labels
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.
Look fine, thank you
Checklist
Thank you for contributing to QuTiP! Please make sure you have finished the following tasks before opening the PR.
You can use pycodestyle to check your code automatically
doc
folder, and the notebook. Feel free to ask if you are not sure.doc/changes/<PR number>.<type>
'type' can be one of the following: feature, bugfix, doc, removal, misc, or deprecation (see here for more information).Delete this checklist after you have completed all the tasks. If you have not finished them all, you can also open a Draft Pull Request to let the others know this on-going work and keep this checklist in the PR description.
Description
This is part of the Google Summer of Code project. My contribution consists of two parts.
One part is organizing arguments of functions in visualization.py. This change helps users to set arguments without referencing documents frequently.
For example, hinton does not have figsize, but other functions such as plot_energy_level do. Also, the order of the arguments varies from function to function, so the user had to see the official document.
I addressed these issues by making the following modifications
First, arguments that many functions should have in common, such as fig and ax, are now keyword arguments.
Second, the order of the arguments was aligned as required arguments, function-specific ones, and common ones, making it easier for the user to remember and use.
The other is applying colorblind_safe to them. QuTiP has colorblind_safe as a setting option, but most functions did not change their color corresponding to colorblind_safe. Now, they change their plot colors when you change the colorblind_safe option and you can change color if you do not like the default color.
For example, when quite.settings.colorblind_safe=False, a plot by plot_spin_distribution is the left plot. On the other hand, when quite.settings.colorblind_safe=False, it outputs the right plot in the different colormap (cividis). This is perceptually uniform. Of course, you can change the colormap as you like.