Skip to content

Conversation

@pingyeh
Copy link
Collaborator

@pingyeh pingyeh commented Oct 9, 2019

After talking to @maffoo, it seems we don't really use wikis for docs, but rather write markdown files in the docs/ directory. Here is the recommendation doc for plotting that captures the requirements and recommended practices for the plot methods.

I have tested the recommended plot method in interactive sessions in colab, ipython and python interpreter. They all work as expected. @Strilanc, can you test it in PyCharm?

@googlebot googlebot added the cla: yes Makes googlebot stop complaining. label Oct 9, 2019
Copy link
Contributor

@Strilanc Strilanc left a comment

Choose a reason for hiding this comment

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

This looks fantastic, Ping. We should have more documents like this. Let's start a dev subdirectory of the docs dir.

@@ -0,0 +1,97 @@
# Recommended interface and behavior of a `plot` method
Copy link
Contributor

Choose a reason for hiding this comment

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

You should create a docs/dev directory and put this inside of it, since this documentation is intended for developers and not users. We can also move development.md into it (but be careful to update any references in sphinx configuration).

a figure and shows it.

The returned `ax` instance can be used to further customize the plot if the
user wants to. Note that if we were to call `plt.show` instead of `fig.show`,
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if we return None when ax is not set? Pycharm seem to require plt.show() instead of fig.show().

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Once plt.show() is called, the figure and ax can no longer be customized (e.g., add grid, change an axis label, etc).

Per offline conversation, the problem is that it doesn't work in the PyCharm environment. The non-blocking fig.show causes the pop-up to not be shown. Is it actually shown but disappears immediately? Is there a setting that can change PyCharm's behavior?

Customizability of plots is not in the current requirements, but I think it is very important. I'd like to add it to the list of requirements.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's fine if we don't support pycharm and instead nag their devs to make it work.

```python
class Foo:
...
def plot(self, ax: plt.Axes=None, **plot_kwargs: Any) -> plt.Axes:
Copy link
Contributor

Choose a reason for hiding this comment

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

Add an import matplotlib.pyplot as plt line. The example testing test is failing because plt is not imported at this point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, though the tests are green before the change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch. That was a bug in the tests. Not it did fail before the move to a subdir of docs. Fixed in #2307

@pingyeh pingyeh requested a review from Strilanc October 10, 2019 04:18
@Strilanc Strilanc added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Oct 10, 2019
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Oct 10, 2019
@CirqBot
Copy link
Collaborator

CirqBot commented Oct 10, 2019

Automerge cancelled: A status check is failing.

@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Oct 10, 2019
@Strilanc Strilanc added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Oct 10, 2019
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Oct 10, 2019
@CirqBot
Copy link
Collaborator

CirqBot commented Oct 10, 2019

Automerge cancelled: A status check is failing.

@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Oct 10, 2019
@dabacon dabacon added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Oct 10, 2019
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Oct 10, 2019
@CirqBot CirqBot merged commit 9bbb10c into quantumlib:master Oct 10, 2019
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Oct 10, 2019
@pingyeh pingyeh deleted the plot-doc branch October 10, 2019 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Makes googlebot stop complaining.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants