Commit Graph

44 Commits

Author SHA1 Message Date
Diego M. Rodríguez 8a01bcb7c7
Update setup.py from requirements (#1527)
* Update setup.py from requirements

Update `setup.py` following previous changes to `requirements.txt`:
* remove `matplotlib` (already in extras)
* move `nxpd` to extras
* move `ipywidgets` to extras
* bump `sympy` to 1.3+
* reorder

* Revise dependencies (ipywidgets 7.3, pydot)
2018-12-18 13:07:01 +01:00
Paul Nation 8a5b221880
Make nxpd optional (#1515)
* make nxpd optional

* add to dev

* updates

* add missing pydot requirement

* lint

* minor msg tweak
2018-12-16 10:32:44 -05:00
Ali Javadi-Abhari b9f33d2bea Refactor DAGCircuit and Unrollers (#1210)
* 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
2018-12-01 08:17:33 -05:00
Luciano fcdb2e150d runtime matplotlib import (#1281)
* 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
2018-11-17 09:09:16 -05:00
Diego M. Rodríguez 2067a18d43
Add auto-validated objects machinery (#1249)
* 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
2018-11-14 11:40:41 +01:00
Kevin Krsulich 233682dd77 Update networkx to 2.2 (#1265)
Fixes #1264
2018-11-13 13:37:03 -05:00
Diego M. Rodríguez 1b879e7177 Copy IBMQuantumExperience 2.0.4 into terra (#1198)
* 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
2018-11-06 20:55:54 +00:00
Diego M. Rodríguez c31dcdc924 Avoid consuming results during `.retrieve_job()` and `.jobs()` (#1082)
* 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.
2018-10-11 11:19:28 +02:00
Salvador de la Puente González 9c8f35eb4e
Adding DAG visualizer (#1059)
This PR introduces a graphical DAG visualizer to ease the task of debugging the transpilation procedure.
2018-10-09 09:35:49 +02:00
Paul Nation c1b40c4bc9 Remove mpl-3 restriction 2018-09-27 05:27:42 -04:00
Diego M. Rodriguez 6f93ff6071 Fix setup.py dependencies
Update `setup.py` with latest dependencies.
2018-09-21 09:46:52 +02:00
Salvador de la Puente González 4c743e9b7e Pinning to matplotlib < 3 to avoid incompatibility issues.
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.
2018-09-20 18:54:39 +02:00
Paul Nation c9c4ed5242
Parallel tools and compiling (#701)
* 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
2018-09-17 23:35:18 -04:00
Salvador de la Puente González c67f33629b Isolate legacy code.
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.
2018-09-14 18:37:30 +02:00
Erick Winston fcaf3d5649 Add support for QObject and pre-QObject formats.
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.
2018-09-14 10:49:57 +02:00
Paul Nation fc221f845b
Properly check if connection can be established for importing interactive visualizations (#892)
* check if has connection

* Removed requests and updated changelog
2018-09-13 11:16:02 -04:00
Matthew Treinish f4303a5d38 Switch to iplot_state by default if env supports it (#862)
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
2018-09-05 13:23:14 -04:00
Diego M. Rodríguez dea7aa7e1e Fix dependencies: add jsonschema, remove vcrpy (#853)
* Fix dependencies: jsonschema, vcrpy

* Add vcrpy to appveyor

* Remove jsonschema from appveyor
2018-09-03 18:37:20 +02:00
Luciano 97d24d1130 Save network interactions to allow tests to run offline by providing mocked responses (#697)
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
2018-08-20 20:42:23 +02:00
Salvador de la Puente González 34358bdbb6 Testing non commercial backends accepts cancellation. (#690)
* 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
2018-08-03 14:14:59 +02:00
Diego M. Rodríguez 8253cf4a98 Use get_status_job() in IBMQJob, bump 1.9.8 (#641)
* 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
2018-07-11 11:47:37 -04:00
Salvador de la Puente González ab54183620 Python3.7 compatibility (#620)
* 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
2018-07-05 23:09:14 +02:00
Diego M. Rodríguez a7984800fe Bump IBMQuantumExperience dependency to 1.9.6 (#600) 2018-06-28 16:59:31 +02:00
Paul Nation 532a7c311c spurious comma 2018-06-13 10:25:41 -04:00
Paul Nation cad289e7be Remove upper bound on dependencies 2018-06-13 10:21:15 -04:00
Diego M. Rodríguez 26a897d603 Bump api version to 1.9.2 (#558) 2018-06-11 12:24:06 +02:00
Paul Nation 5c1c68a5aa Bump upper limits on requirements packages to next minor release number (#509)
* Increase upper bounds on packages
2018-05-29 09:34:22 +02:00
Juan Gomez 72eae89453 CMake improvements! (#468)
* 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
2018-05-15 19:04:04 +02:00
Diego M. Rodriguez 2de3efa62c Bump IBMQuantumExperience version 2018-05-11 20:48:24 +02:00
Diego M. Rodríguez b6815da4f5 Bump IBMQuantumExperience dependency to 1.9 (#437) 2018-04-30 13:17:14 -04:00
Diego M. Rodriguez 3dbcd7bf20 Bump API version, fix check, _AssertNoLogsContext
* 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.
2018-03-19 15:03:39 +01:00
Juan Gomez cd1b1067de
Merge pull request #327 from diego-plan9/fix/api-version
Bump IBMQuantumExperience dependency version
2018-03-09 16:59:34 +01:00
Luciano ae7790c9b0 the compilation output should not depend on the Python version (#313)
* 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.
2018-03-09 16:38:20 +01:00
Diego M. Rodriguez 504f7e0308 Bump IBMQuantumExperience dependency version
Bump the required version of `IBMQuantumExperience` version, as it
includes a fix for the latest errors with hpc and ibmqx2 backends.
2018-03-09 14:53:21 +01:00
Diego M. Rodriguez de5a9415e8 Revise travis configuration, using cmake
* 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`.
2018-02-22 14:56:20 +01:00
Ali Javadi-Abhari c30110e208 Circuit image plotter (#295)
* 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
2018-02-19 10:59:47 +01:00
Luciano 3372a4d6fb Remove setuptools.setup mock (#286)
* tests for _util.py

* remove mock mess. KISS by reading the file directly.
2018-02-12 20:35:19 +01:00
Juan Gomez 87a995b2d8
Upgrade QISKit depdencies (#261)
* 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.
2018-01-22 15:17:31 +01:00
Diego M. Rodríguez 5ecf64ca88 Revise dependencies, allow more recent versions (#238)
Revise the dependencies in order to:
* drop `requests`, as it is not needed directly by the SDK
* for several packages, test that the most recent *major* versions of
  them work with QISKit, and adjust the comparators accordingly.
* fix a test that was failing due to the precision.
2018-01-09 19:33:50 +01:00
Ali Javadi-Abhari 355b2503eb Updating required version for IBMQuantumExperience (#231)
* one more initializer test case

* updating version requirement for IBMQuantumExperience

* fixing per diego's comments
2018-01-05 16:51:25 +01:00
Diego M. Rodriguez 465d15a30d Add test for invalid IBMQ creds, bump API version 2017-12-07 21:13:53 +01:00
Diego M. Rodriguez ba210b0d25 Update quantumprogram for using IBM Q parameters
Update QuantumProgram.set_api() and add a new set_api_hubs_config()
method for being able to pass hub, group and project parameters to the
API, and modify it.
2017-12-07 21:13:53 +01:00
Luciano 6b4c3502da Issue 111 - Math domain error fix
* Switch from math package to sympy in order to avoid floating point precision errors
2017-11-17 18:19:48 +01:00
Diego M. Rodríguez b2d6e70229 Check IBMQuantumExperience version at runtime (#115)
* Add runtime check for IBMQuantumExperience version

Add `qiskit._util._check_ibmqe_version()` (invoked on the main import)
for emitting a warning if the installed version of IBMQuantumExperience
does not match the version defined on `setup.py`.

* Rename requires.txt and requires-dev.txt

Rename to "requirements.txt" and "requirements-dev.txt", in order to
conform better to the de-facto practices.
Update the requirements to match the versions specified in setup.py.

* setup.py: OS classifiers, backend, IBMQE version

* Explicitly require IBMQuantumExperience>=1.8.13, as older versions
  might not contain all the functionality needed.
* Include "qiskit.backends" as a package instead of "qiskit.simulators".
* Add trove classifiers for the operative systems supported.
* Fix PEP8 warnings for long description.

* Avoid using __version__ in setup.py due to imports

Revert the change of using "__version__" imported from "__init__.py"
directly on "setup.py", as the current importing of the modules from
"__init__.py" causes the building to fail due to the dependencies not
being available at the time of invocation.
2017-10-25 10:12:04 -04:00