* Rewrite dag drawer to not use nxpd
The nxpd library is quite stale and hasn't seen an update in 3 years.
The most recent release of networkx 2.4 is incompatible with nxpd now
because nxpd was using deprecated (and now removed) api calls from
networkx. Additionally, the functionality provided by nxpd already
exists in networkx so there is no reason to rely on an additional
library outside of networkx and pydot. This commit updates the dag
drawer to no longer use nxpd and uses networkx's drawing features
instead.
* Cap networkx for python 3.5
In the networkx release notes for 2.4 [1] it states clearly that the 2.4
release is the last release with python 3.5 support. Since the release
timeline is not fixed and we may end up support python 3.5 in terra
longer than networkx this adds a capped version of networkx on 2.4 for
python 3.5.
[1] https://networkx.github.io/documentation/stable/release/release_2.4.html
* Adjust python 3.5 cap
Since networkx 2.4 is seemingly relying on the guaranteed insertion
ordering for dicts introduced in 3.6 for how we're using topological
sort this adjusts the cap previously introduced to be <2.4 instead of
<=2.4. This should avoid the failures related to this on python 3.5 and
networx 2.4.
* Avoid duplicate requirements with cap
* split!
* passes()
* max_iteration
* replace
* some RunningPassManager clean up
* callback support
* property_set result
* lint
* cleaning up runninpassmanager
* docstring
* args
* parallel
* test
* parallelize using dill
* dill in requirements.txt
* lint
* runningpassmanager style
* dill in setup
* fix the drawer with the new format from passes
* new refs
* Update qiskit/visualization/pass_manager_visualization.py
Co-Authored-By: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
* no label for linear
* refs
* _pass_sets
* pass set in a docstring
* lint
* different circuits
* circuit_or_circuits -> circuits
* Remove silencing ChangedInMarshmallow3Warning
* Fix passing missing when required=True
* Handle unknown keys via unknown=INCLUDE
* Update ModelValidationError
* Update qiskit.validation.fields
* Add **kwargs to different functions
* Remove explicit strict parameter
* Update imports and other tweaks
* Remove load_additional_data from base
Remove the load_additional_data hook, as it is handled by the `unknown`
mechanism.
* Update kwargs for base
* Update dump and load expected return
* Updates and tweaks to fields
* Fix wrong `Mapping` import introduced in an eaerlier commit.
* Expand the `ByType` catching of unserializable/undeserializable fields
as exceptions are no longer swallowed.
* Adjust to renamed `container` member.
* Use make_error instead of fail
* Wrap serialize errors into dict
During a field's `_serialize`, the exceptions raised did not contain
the nested structure that allows identifying the field. This commit
updates `InstructionParameter` so the message is nested.
* Use pre_load for qobj.type and qobj.schema_version
* Lint and kwargs fixes
* Bump marshmallow and marshmallow_polyfield version
* Revert extra import
We have had the jsonschema version capped since it was introduced as a
requirement into terra. There is no clear reason for this and it limits
interoperability with other python packages. Especially because
jsonschema is commonly used library across the python ecosystem. The
version we were capping to was also quite old being release 2.5 years
ago. This commit removes the cap so that people can run terra in
environments where newer jsonschema is required.
* Make pylatexenc and pillow optional
The pylatexenc and pillow requirements are only used in the latex and
latex_source circuit drawers. Since this isn't used by everyone and is a
non-default circuit drawer there is no reason we should force our users
to install these by default. This commit updates the requirements list
and setup.py to make these 2 requirements optional and included in the
visualization setuptools extras to ease installation. If the packages
are not installed it will raise an ImportError with a detailed exception
explaining how to install the missing dependency.
Fixes#2417
* Fix lint
* Fix lint again
* Use pylatexenc utf8tolatex for gate names in latex drawer
When the latex drawer goes to draw custom gates they can be named and
valid unicode string. That's because the gate name attribute is a
string. However, latex doesn't know how to handle all utf8 characters
and requires escaping or custom libraries to render many of them.
Instead of trying to handle every edge case this commit uses the
pylatexenc lib (which is a MIT licensed lib with no additional
dependencies) which contains a mapping of all the unicode characters
with the latex equivalent. This means that things like '_' in custom
gate names will render properly now.
Partially Addresses #2235
* Fix lint
* Remove numpy max version cap
The version cap was put in place to prevent a potential incompatibility
but removing doesn't seem to cause any issues. Having it in place on
terra will cause an issue with ignis which requires numpy>=1.16.0 to
work as expected. While they're both co-installable because pip doesn't
have a depedency solver this only works if ignis is installed second.
(as installing terra second pip will use it's requirements with the
version cap, instead of ignis which has already been installed). To
avoid any potential confusion just removing the version cap is easiest.
* Disable misbehaving pylint checks
* Remove documentation deploy
Remove documentation script and travis job.
* Remove deploy stage from travis
Remove the "deploy doc and pypi" stage entirely, and revise the
"subclassing" of the osx jobs.
* Fix travis script make invocation
* Fix extra lint script commands
* Pin numpy version to <1.16
Pin the numpy version to <1.16 until the potential incompatibilities
are fixed.
* Remove numpy from whitelist, ignore random instead
Remove `numpy` from the `extension-pkg-whitelist`, and instead manually
ignore the check for the members of `numpy.random`, as it was the
only place where the check was significant.
* apply_operation_back/front take the op object
* remove wire_type and index input/output_map over objects
* restore qargs/cargs fields to op nodes
* define wire as (Register,int) object
* remove unused concept of precision in unrollers and dag
* add more dag tests. new function get_op_nodes
* factor out tests into setUp
* update unrollers
* simplify dagunroller and dagbackend
* decomposition rules in gate definitions as list of DAGs
* fix cyclic import by moving visualization import inside circuit.draw()
* recursive unrolling until hitting basis
* adding more mini dags to standard gates
* fix unroll AST to DAG
* update test_unroller.py
* convert load qasm to go qasm, ast, dag, circuit.
* remove unrollers _circuitbackend and _printerbackend
* instruction.param are qasm.node objects. convert to real or sym at your will.
* tweaks to jsonbackend and dagbackend
* return register objects in visualization.utils.get_instructions.
visualizers get param from node['op'].param now.
* Instruction param as sympy objects
* unify generation of json for all instructions, including basics
* update aer tests to not use unrollers, add simulator extensions as dag
basis
* clean decomposition rules per gate
* snapshot label/slot must be string. clarify allowed instruction param formats
* style and lint
* make all node names str.
* update mapper to new dag
* docstring
* lint
* broken test/python/aer/test_statevector_simulator.py
* lint
* bug
* fix bug in constructing DAG from AST node with conditional
* fix get_instructions test
* tests
* test_dagcircuit.TestDagRegisters.test_add_qreg_creg had empty assert
* get_qubits
* fix accessing None conditions
* fixing backend configuration to new diego style
* test dag equality not qasm equality
* fixes#1235 by @1ucian0
* use bin_to_hex_keys in qasm simulator py test
* update swap mapper to work with new dag
* ground truth in test.python.circuit.test_circuit_load_from_qasm.LoadFromQasmTest
* import errors
* test_qasm_file
* update check on qargs
* binding mistake
* some variation in the test
* fix serializing QuantumRegister for c++ sim
* op.qargs -> qargs
* test.python.test_mapper.TestMapper.test_yzy_zyz_cases
* fix some mapper tests. json backend gets qarg from node['qarg'] not op.qarg
* keep layouts in old format in transpiler. convert to (reg, int) in mapper
* check_map
* lint
* run a slow test with cpp simulator
* typo
* test.python.test_mapper_coupling
* temporarily skip two tests due to wire fragment bug in mapper
* test_circuit_operations.py
* test_dag_to_dag_expand_gates_default_basis
* test_from_ast_to_dag
* test_qobj_2_circuits
* style in qiskit/
* style in test/
* docstrings in DAGCircuit
* circuit equivalence
* dag comparison
* pass correct conditional in apply_operation_back
* re-remove get_qasm_snapshot test
* lint
* CHANGELOG. update sympy requirement.
* replace one more qasm comparison with circuit comparison
* readjust the tests
* linting
* no skip in test_visualization
* a deeper catch
* simpler
* test_qcvv_fitters does not depend on matplotlib
* matplotlib from requirements to requirements-dev
* style
* linting
* Add skeleton models and schemas in qiskit.models
Add `qiskit.models`, with the basis for defining objects (models) that
are used for interfacing with terra and formally defined in the specs
(schema). The classes in `base` are meant to be subclasses for each
entity - an example is included in `backend_status`.
* Update requirements
* Add tests for qiskit.models
* Adding validator decorator and moving to Marshmallow 2 (#7)
* Adding validator decorator and moving to Marshmallow 2
* Adding docstrings
* Documenting returns
* Feature/polyfields (#8)
* Moving validation infrastructure to qiskit.validation
* Providing a PolyField basic implementation
* The decorators raises when trying to bind the same schema twice.
* Better PolyField building blocks
* Move fields to own file, tweak and document
Move the Fields related code to `qiskit.validation.fields`, for clarity.
Update `BasePolyField` and `TryFrom` with tweaks to match the expected
functionality, linter and add documentation. Add tests, reorganizing
them slightly into TestCases.
* Revise validation documentation
* Add ByAttribute polymorphic field, fixes
Add the `ByAttribute` polymorphic field, allowing to chose an schema
based on the presence of an attribute. Fix the `to_dict_selector`s in
order to use inspection on the Models directly. Add tests.
* Remove BackendStatusSchema
Remove the `BackendStatusSchema` implementation, in order to introduce
it in future PRs along with its usage.
* Allow for top-level validation in instantiation (#9)
* Allow for top-level validation in instantiation
Update the instantation of a `Model` from kwargs in order to perform
a validation of the regular, top-level fields but not full validation
of the compound fields via a `schemalite` attribute.
* Update top-level validation during instantiation
Fix top-level validation during instantiation, making it take into
account other types of fields. Update tests and style and naming
tweaks.
* Rename test_models to test_validation
For consistency with the module name `qiskit.validation`.
* Updates to validation.base from review
* Copy IBMQuantumExperience 2.0.4 into ibmq
Copy the `IBMQuantumExperience` files (version 2.0.4, 2ab2401) into
the `qiskit.backends.ibmq.api` package. The credit for the code is for
@pacomf with the help of contributors in the original repository [1].
[1] https://github.com/Qiskit/qiskit-api-py
* Lint and style fixes for IBMQuantumExperience
* Linter warnings for IBMQuantumExperience
Less trivial fixes for linter warnings:
* simplify run_experiment return logic
* add `requests.codes.ok` to list of generated members, as they are
populated dynamically
* disable a spurious urllib3 import
* Rename IBMQuantumExperience to IBMQConnector
* Replace IBMQuantumExperience usages
Replace the usages of `IBMQuantumExperience` with usages of
`qiskit.backends.ibmq.api.IBMQConnector`, updating docstrings and
text in the process.
Update the dependencies accordingly.
* Remove functions from qiskit._util
Remove or move several functions from `qiskit._util`:
* remove `_check_ibmqx_version`, as it has been rendered obsolete
* move `_dict_merge` to qiskit.backends.ibmq
* remove `_parse_ibmq_credentials`, as it was unused
* Add IBMQConnector tests
Add tests for IBMQConnector, copying them from the original repository
and adjusting for style and conformance to Terra testing structure.
Original work by @pacomf and contributors at qiskit-api-py.
* Disable api.run_experiment tests
Disable the tests related to api.run_experiment(), as the function is
not used in terra.
* Remove test_util
* Update CHANGELOG
* Replace API calls with lightweight status calls
In `IBMQJob`, replace the calls for listing jobs and retrieving a
previous job with the new endpoints that provide enough info for
recreating a `Job` based on them. The side effect is that the results
are not consumed until `job.result()` is called.
* Use API status in IBMQJob constructor
Allow passing the API status field to the IBMQJob constructor in order
to avoid extra API calls when constructing an already sent job.
New matplotlib 3.0 version breaks backwards compatibility by raising
an ImportError when Python is not installed as a framework in MacOS X.
This PR pins Matplotlib to versions under 3.0 since it is the fastest
way to ensure we are not introducing breaking changes in visualization
tools given the proximity of the new release.
* Parallel tools and compiling
* add blank line
* Add parallel compile test
- Also try to work around lint and optional imports
* disable import-error for optional import
* fix indent
* Major update wiht magics
* fix compile lint
* fix style
* disable import errors
* white space
* Add compile with TextProgressBar test
* Remove jupyter components
* shorten parallel test time
* Minimize the parallel routines
* cleanup merge
* updates
* more updates
* fix comtypes issue
* add comtypes
* make comtypes requirement on windows
* update changelog
* review updates
* more updates
* remove callback function
* fix conflict
* Add progressbars back
* fix lint errors
* better grabbing of progress bars
* grab bars in order created
* Make jupyter tools availabel by default
* fix circular import
* switch used order
* fix move lint disable
* fix signature
* fix changelog and releases
* revert erroneous changes from git history
* revert one more
* add back psutil requirement
* remove high-level imports
* refine changelog
* move everything to transpiler folder
This PR factor out the decisions about when to use the new implementation
for Qobj-based jobs (IBMQJob) or the previous one (IBMQJobPreQobj) and a
bungh of module-level functions.
For distinguishing between jobs sent using Qobj or the old format, the
backend team included a `kind: "q-object" field in the job response.
After conversations with the backend team, it is assumed that all the
backends should answer with the new QobjResult format if the job was a
Qobj-based job and with the previous format if the job was using the old
format.
The PR also extends `from_dict` capabilities to cast numpy types to Python
types.
This PR modify IBMQ backends to create QObject or pre-QObjects jobs.
It also consider scenarios when a mixture between new and old jobs can be
retrieved. For instance and during the transition when asking for past jobs.
New jobs are a subtype of `IBMQJob` named `IBMQJobPreQobj` and it's intended
to be deprecated.
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.
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
The current commit introduces several changes to the testing infrastructure.
First, it provides a way of running IBM-Q tests against pre-recorded responses. The software in charge of recording and mocking-up the responses is VCRPy[1] and it is configured and used in `test/common.py`. Cassettes can be updated by using `make test_recording`.
[1] https://github.com/kevin1024/vcrpy
The commit also includes the latest responses (under `tests/casettes`) for a successful test run but a default execution with `make test` will only use them if no IBM-Q credentials are found. To force a run against mocked responses, use `make test_mock`.
Finally, the commit also unifies the several test options in a unique environmental variable called `QISKIT_TESTS` (in `tests/python/_test_options.py`). These are the main equivalences but the set of options is described in the developer introduction [2]:
- `SKIP_SLOW_TESTS=False` is now achieved by `QISKIT_TESTS=run_slow`
- `SKIP_ONLINE_TESTS=1` is now achieved by `QISKIT_TESTS=skip_online`
[2] https://github.com/Qiskit/qiskit-terra/blob/master/doc/dev_introduction.rst#testing-options
* Testing non commercial backends accepts cancellation.
* Passing linter
* Marking test_cancel of ibmqjobs as slow
* Factoring out job tests-specific methods.
* Adding changelog modification
* Increasing timeout
* Distinguishing backend in case the tests are passed with IBM-Q credentials
* Use get_status_job() in IBMQJob, bump 1.9.8
Use the recently included `api.get_status_job()` for checking the
status of an online job, as it is more performant than the existing
`api.get_job()`. Bump IBMQuantumExperience dependency.
* Update changelog
* Adding Python 3.7 to the Travis Matrix for Linux and OSX.
Waiting for Appveyor to support Python 3.7 natively before adding it to the matrix.
* Used pyenv and venvwrapper for both OSX stages.
* Update OSX Python 3.7 stage key
* CMake improvements:
* Static linking is not the default anymore.
* Platform Wheel Tag is now configurable via cmake variable.
* Updated documentation
* CI config file updated accordingly
* Added support for Win64 builds on Visual Studio 2017
* Windows C++ Simulator now links with a prebuilt version of
OpenBLAS (64 bits), so there's no need to link against
LAPACK anymore
* cmake added as a dependency
* Restored --static-libgcc flag for static MacOS builds so gcc
can create *semi* static executables again. Clang doesn't have
static compilation.
* Remove default WHEEL_TAG value so if not specified, the tag is
choosen by the wheel module
* Bump `IBMQuantumExperience` dependency to 1.8.29, as it fixes a bug
and will be required by the next sdk release.
* Fix the `_check_ibmqe_version()`, as after #286 there where cases
where the `requirement.txt` file was not present, resulting in the
wrong warning. Now uses a simple approach: the check is only performed
if installed via pip, assuming in the rest of the cases the user is
responsible for updating the dependencies (ie. `pip install -U`).
* Revise `_AssertNoLogsContext` in order to produce more informative
failure messages.
* removing ambiguities that created different compilation results in different python versions
* linting
* Bump networkx to >=2.0 in setup.py
* Fix results and bug for test_run_async_stress
Fix the values expected by the test_run_async_stress test in order to
match the ones produced with networkx 2.0.
Fix a bug re-raising the exception when that test fails, and a linter
issue from a previous PR.
* Revise the travis configuration for using `cmake` for the several
targets, and use "stages" instead of parallel jobs:
* define three stages that are executed if the previous one suceeds:
1. "linter and pure python test": executes the linter and a test
without compiling the binaries, with the idea of providing quick
feedback for PRs.
2. "test": launch the test, including the compilation of binaries,
under GNU/Linux Python 3.6 and 3.6; and osx Python 3.6.
3. "deploy doc and pypi": for the stable branch, deploy the docs
to the landing page, and when using a specific commit message,
build the GNU/Linux and osx wheels, uploading them to test.pypi.
* use yaml anchors and definitions to avoid repeating code (and
working around travis limitations).
* Modify the `cmake``configuration to accomodate the stages flow:
* allow conditional creation of compilation and QA targets, mainly
for saving some time in some jobs.
* move the tests to `cmake/tests.cmake`.
* Update the tests:
* add a `requires_qe_access` decorator that retrieves QE_TOKEN and
QE_URL and appends them to the parameters in an unified manner.
* add an environment variable `SKIP_ONLINE_TESTS` that allows to
skip the tests that need network access.
* replace `TRAVIS_FORK_PULL_REQUEST` with the previous two
mechanisms, adding support for AppVeyor as well.
* fix a problem with matplotlib under osx headless, effectively
skipping `test_visualization.py` during the travis osx jobs.
* Move Sphinx to `requirements-dev.txt`.
* one more initializer test case
* updating version requirement for IBMQuantumExperience
* fixing per diego's comments
* circuit_drawer() visualization.py, generating PIL images
* adding circuit drawing function and embedded example in initialize
* added test
* linting
* more linting
* better exception handling in case dependencies not installed.
* fixing circuit drawing tests
* more linting-_-
* fixing per diego's comments
* lint
* improved exception handling for dependencies pillow, poppler, pdflatex, qcircuit
* adding id to drawing basis default
* Fix typo in setup.py.in
* Bumped to version: 0.4.6
* Upgraded external dependencies
* Make graph code in QISKit compatible with NetworkX 2.0
NetworkX 1.11 which is required by qiskit uses some deprecated
functions for plotting that generate a warning with matplotlib. The
proposed changes make QISKit compatible with both versions of NetworkX.
In a second step we should upgrade the code to use only NetworkX 2.0
and later since some functions were added that make things more
elegant. See
https://networkx.github.io/documentation/stable/release/migration_guide_from_1.x_to_2.0.html
* Reintroduce AppVeyor (#252)
Re-enable the AppVeyor CI, as the conflicts with the version were
hopefully solved after bumping the scipy dependency and others.