Switch to iplot_state by default if env supports it #862
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This commit switches the default graphing method to use the interactive
plot_state method if the environment conditions support it. There are 2
conditions when iplot_state can be used, the first is that things are
running inside jupyter, the second is that the environment has an
internet connection and can reach the js source needed for the
visualization. This will verify these 2 conditions by checking if the
ipykernel module is present and they trying to do an HTTP GET on
the url where the page is hosted to verify the plot function can do the
same.
Details and comments
The requests library is used directly to perform the HTTP GET call so it
is added to the requirements.txt file in this commit. However this was
already an implicit requirement for qiskit-terra because it's what the
IBMQuantumExperience package uses for its HTTP client. This only adds it
to the requirements file because it is now directly called.
Fixes #806