Commit Graph

1168 Commits

Author SHA1 Message Date
Daniel Puzzuoli d5e9a3b1d0 pulse Schedule not filter (#3361)
* added filter_type argument to pulse.Schedule.filter to enable switching between filtering, inverse filtering (i.e. keeping instructions that fail some filter), or returning both

* fixed error in the way Schedule._filter() was constructing total_filter

* added testing for pulse.Schedule.filter in the filter_type=1 case

* adding tests for Schedule.filter for the new filter_type=1 and filter_type=2; however too much repeated code, will simplify

* simplified test cases in test_schedule.TestScheduleFilter to simultaneously test all options of filter_type=0,1,2. All original tests have been retained

* Removing filter_type argument from Schedule.filter, and adding a Schedule.exclude method

* fixing the way Schedule.filter deals with un-keyed arguments in the filter_func argument. Modified tests to deal with new method signature for Schedule.filter and Schedule.exclude

* updated tests in test_schedule.TestScheduleFilter to reflect new changes to Schedule.filter and Schedule.exclude

* fixed stylistic issues in schedule.py and test_schedule.py

* corrected style in Schedule.filter and Schedule.exclude, and test_schedule.py

* added a new method Schedule._apply_filter to refactor duplicate code from Schedule.filter and Schedule.exclude

* corrected error in Schedule._apply_filter

* minor changes to comments in schedule.py

* Update qiskit/pulse/schedule.py

Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com>

* Update qiskit/pulse/schedule.py

Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com>

* Update qiskit/pulse/schedule.py

Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com>

* Update qiskit/pulse/schedule.py

Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com>

* fixing comments in filter and exclude methods in schedule.py

* Removed unnecessary lines from Schedule._construct_filter
2019-11-06 16:11:28 +00:00
Luciano edf2c497d5 Add layout score analysis pass (#3321)
* initial commit

* docstring

* docstring

* Update qiskit/transpiler/passes/mapping/layout_score.py

Co-Authored-By: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>

* += -> =

* docstring

* remove initial_layout param

* rename qiskit/transpiler/passes/mapping/layout_score.py qiskit/transpiler/passes/mapping/layout_2q_distance.py

* LayoutScore -> Layout2qDistance

* counter

* dyn property name

* docstring

* release note

* each two qubit gate in the circuit
2019-11-01 21:02:14 +00:00
Luciano 37d51af53f no more random in test_visualization (#3365)
* no more random in test_visualization

* lint

* lint!

* gate -> qubit
2019-11-01 14:43:13 +00:00
Luciano cd4e2a163a FullAncillaAllocation and EnlargeWithAncilla do not allow initial_layout at construction time (#3363)
* enlarge_with_ancilla

* full_ancilla_allocation

* new refs
2019-11-01 00:36:06 +00:00
Diego M. Rodríguez 291d47a12a Allow bypassing validation during model instantiation (#3368)
* Tweaks to validation/base docstrings

* Use "validate" constructor attribute

* Update validation.base docstrings

* Add test

* Adjust quotes in docstrings

Actually doubling as a re-triggering of CI.
2019-10-31 15:02:31 +00:00
Jack J. Woehr 299277d35e Add Instruction.is_parameterized() (#3328)
* added Instruction.is_parameterized()

* Applied new method Instruction.is_parameterized() in obvious places.
Added test case for Instruction.is_parameterized().

* release note for Instruction.is_parameterized

* Cleaned up for linter.
Added typographical style to release note.

* Added bound parameter test to test_is_parameterized()

* Added detail to release note.

* Updated the cases in Collect2qBlocks and CommutationAnalysis

* changed test to bind parameter to instruction in approved fashion

* corrected test
2019-10-30 16:55:29 -04:00
Lauren Capelluto 2ad7a666b4 Add useful methods to PulseBackendConfiguration (#3309)
* Add useful methods to PulseBackendConfiguration. This will remove the need for the redundant PulseChannelsSpec class in pulse.

* Add release notes

* Style: Remove unused import

* Remove old test

* Fix issue in test: plot gate map only works with > 5 qubits

* Respond to feedback: Valid + realistic hamiltonian in mocked configuration, releasenotes augmented to alert users of dt/dtm change, hamiltonian methods on config return whole hamiltonian + tests updated to match, and dt/dtm are put it proper units during init rather than access

* Style
2019-10-30 17:34:25 +00:00
faisaldebouni 556c2df4ab Add support for slicing and concatenation of PassManagers (#3209)
* implemented functions to enable slicing and concatenation of PassManagers

* fixed errors, added release notes, added unittests

* resolving conflict

* adapter implementation to new PassManager

* fixes a bug caused by shallow copy

* test name capitalization
2019-10-30 12:01:56 +00:00
Kevin Krsulich c96baad5c6 Unroller and Optimize1QGates to use single node substitution (#3233)
* DAGCircuit.substitute_node should respect name from replacement op.

* Remove unroller error message resolved by #3148.

* Unroller and optimize_1q_gates to use substitute_node when possible.
2019-10-30 01:36:22 +00:00
Lauren Capelluto 600b8b2415 Fix bug in align_acquires where measurement pulses had to be added before AcquireInstructions (#3307) 2019-10-29 13:50:50 -04:00
Luciano 6745b1ecec
Parallel support for PassManager.run() (#3290)
* 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
2019-10-28 14:29:23 -04:00
Matthew Treinish fb87e7c2e2 Add dual of mpl mathtext syntax for latex drawer labels (#3224)
* Add dual of mpl mathtext syntax for latex drawer labels

This commit adds a new feature to the latex drawer that adds support for
a similar syntax to matplotlib's mathtext to labels on the latex drawer.
In matplotlib if you specify a string between two dollar signs (for
example $\gamma$) that string will be parsed with mpl's native TeX
expression parser and that will be used to layout and render the string
per the TeX syntax. This uses the same syntax as mathtext, and enables
users to write raw latex syntax as gate labels between a pair of dollar
signs. All characters outside of the dollar signs are treated as utf8
and get encoded by pylatexenc to create valid latex, however all text
inside the dollar signs get passed verbatim to the output latex. This
enables users to mix and match having their unicode encoded for them and
manually passing latex

Fixes #3171

* Fix lint

* Use jupyter-execute instead of describing diagram

* Revert "Use jupyter-execute instead of describing diagram"

This reverts commit ab7bc18c39. Running
the code example in jupyter-execute will require a latex distribution
with qcircuit to be installed. That adds a lot of run time to the doc
build and a non-obvious dependency. To avoid this, we'll just rely on
the code example and a description of the output.
2019-10-28 13:54:59 -04:00
Kevin Krsulich d53197a0c8
Collect2qBlocks, CommutationAnalysis to ignore parameterized gates. (#3288) 2019-10-28 12:18:02 -04:00
Luciano 10896b56e3
CouplingMap.distance was returning non-int (#3323)
* cast!

* internal matrix whats to be float
2019-10-26 21:33:50 -04:00
Maddy Tod 277407c055 Added in custom unitary to qasm (#3069)
* Got a method that makes accpetable qam

* Added in a comment to remind myself

* Made some more minor changes

* Added in a test

* Updated variable naming to make clearer

* Tidying up for clarity

* Fixed typo in test

* Made the added fields private

* indexing openqasm

* Fixed spelling mistake and added in a test for multiple calls to the qasm algorithm

* Added in a test for 2 qubit unitaries to convert to qasm

* lint

* lint
2019-10-24 16:53:25 -04:00
AzizNgoueya 4199bcd71b Auto Scale PulseScheduler drawing (#3180)
* Scaling=None

Changes default scaling for Schedule drawing from 1 to None

* Auto scale PulseScheduler drawing

Extra code for scaling automatically pulse schedule drawing for given channels

* Update matplotlib.py

* Update matplotlib.py

* Update matplotlib.py

* Update matplotlib.py

* Update matplotlib.py

* Add a boolean parameter for removing spacing

* delete the spacing by changing the y0 offset

* New images for testing pulse visualization

* Update matplotlib.py

* Update matplotlib.py

* include non-zero negative values with small amp

* scale the y0 offset with minimum amplitude

* Uptdate reference files for testing
2019-10-24 11:49:52 -04:00
Christopher Zachow 1e3c165611 TranspilerAccessError is deprecated in favor of TranspilerError (#3222)
* deprecated TranspilerAccessError in favour of TranspilerError

* changed version for deprecation

* fixed linting errors

* fixed unused import

* added changelog and fixed deprecation
2019-10-24 11:09:07 -04:00
Matthew Treinish 4a6eb32337
Mostly remove sympy and deprecate sympy Instruction parameters (#3156)
* Remove sympy from everywhere

This commit removes all the sympy usage from qiskit-terra. Sympy is very
slow, not just to perform computations, but also to just import (being
the second slowest import in terra, only behind qiskit.version which
calls git and pip in a subprocess) and doesn't actually provide us any
real advantages inside terra. None of the expressions or calculations
terra is doing need to be done symbolically, and using sympy as just an
output formatter (to get pretty output for things like pi) is overkill.

* Fix lint

* Fixes from running openqasm conformance tests

* Import sympy lazily for circuit Parameters.

* Add back sympy to requirements

While sympy has been removed from most places in the repo as of this
point, it is still used internally in the Parameter and
ParameterExpansion classes. The imports there have been made runtime to
remove the import performance impact and they are self contained in
those classes as of this commit. We can remove sympy from the
requirements in the future when we come up with way to replace the
parameter classes' use of sympy we can remove it from the requirements
lists.

* Make type warning a deprecation warning

* Fix rebase issue (and unnecessary runtime import)

* Update instruction parameter type handling

This commit updates some issues found during code review with the
parameter handling. Now instead of casting string parameters as a float
incorrectly, this uses them to create a new symbolic parameter. Also for
numpy number types that are not caught by the earlier type checks item()
is called as was the previous behavior.

* Revert switch from Node.sym->Node.num()

For ast Node parameter types that were passed as parameters for an
instruction the method call to get the value was incorrectly changed
to num() from sym(), which doesn't exist. This was a sloppy regex find
replace that did it by accident. This commit reverts that mistake and
restores the functionality.

* Deprecate not remove sympy.basic and sympy.matrix params

This commit adds back support, albeit it deprecated form, for passing in
instruction parameters as sympy.basic and sympy.matrix objects. It also
updates the release notes to reflect this change.

* Add deprecation for sympy.Expr instruction param too

* Update release notes

* Remove sympy types usage from unit tests

This commit removes the usage of sympy types from unit tests. There were
several cases of unit tests that were using sympy's pi or similar
constants for no particular reason. Since this usage is now deprecated
it is better to remove this. The only sympy usage that remains in the
tests now are for test cases that are explicitly testing behavior with
sympy. These will remain until the sympy support has been removed since
we need to verify that the deprecated feature still works as is until
removal.

* Update release of deprecation to 0.11.0

* Update changed error exception class

* lint
2019-10-23 16:15:44 -04:00
Lauren Capelluto 9e32d58c88 Remove buffer options in Pulse (#3297)
* Deprecate buffer options in Pulse

* Fill in warning message, update tests

* Add reno note

* Remove unused MeasureChannel import
2019-10-23 15:54:16 -04:00
Kevin Krsulich a9cb4c3d02 instruction.copy().params does not modify the original instance 2019-10-23 14:50:18 -04:00
Luciano 8497d1ebd5 A simpler pass manager (#3286)
* split!

* passes()

* max_iteration

* replace

* some RunningPassManager clean up

* callback support

* property_set result

* lint

* cleaning up runninpassmanager

* docstring

* args

* runningpassmanager style

* 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
2019-10-23 13:09:15 -04:00
Rafael Martín-Cuevas Redondo c81402447c The exceptions QiskitError qiskit/circuit/* are being replaced by CircuitError (a QiskitError subclass) (#3210)
* #3204 Replace QiskitError with CircuitError in qiskit/circuit/*.

* Minor style fixes.

* Minor style fixes.

* Update copyright at qiskit/circuit/exceptions.py

Co-Authored-By: Luciano <luciano.bello@ibm.com>
2019-10-22 15:39:47 -04:00
brandhsn 31cdd7428c Removed the usage of stochastic swap trivial_flag as it can lead to single-qubit gates being omitted (#3285)
* removed usage of trivial_flag that indicates when a layer should be skipped by layer_update (#3197)

* removed trivial_flag from stochastic_swap and added a test for omitted gates

* lint
2019-10-22 09:38:39 -04:00
Maddy Tod 812e213a01 Fix failing PassManager visualization tests (#3284)
* Updated the reference files

* Install graphviz in linux test jobs
2019-10-21 17:01:39 -04:00
SooluThomas fcfdb8be1a Added new methods to BackendProperties (#3131)
* Added get method

* Added new usability methods

* Standardized code, added error messages and get_gate_property

* Added missing import statements

* Updated error messages

* Added Tests

* Added Tests

* Removed unwanted error messages

* Added _to_tuple

* Updated fake_openpulse_2q.py

* Removed the backend properties test

* Added tests for backend properties

* Added Fake openpulse

* Added _to_tuple

* added typehints to gate_error

* Added tests

* Removed _to_tuple

* fix lints

* fix lints

* Tests

* Updated gate_error and gate_length

* Standardized Docstrings

* Added gates and qubits for backward compatibility

* Changed get_gate_property to gate_property

* Changed get_qubit_property to qubit_property

* Fix lint of gate_property

* Change the parameter name of gate_property to operation

* Added warning for qubit=None and name=not none

* Added tests to check PulseError

* Lauren's bug fix

* Added another exception raise to gate_property

* Remove comments and fixed a lint error

* Changes from review

Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com>

* Changes from review

Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com>

* Removed defaultdict

* patches

* Removed unused imports

* Fixed few lints

* More Changes to docstrings and dict logic

* Updated docstrings

* Updated typehints and fixed lint

* Fix travis lint error

* revert the code from line 68-102

* Edit json file with incorrect entries

* Change return to returns in docstring

* Fix lints

* fix lints

* Fix lint

* Fix Lint

* fix Lints

* Revert "fix Lints"

This reverts commit d8c30d71e0.

* fix Lint

* Fix Lint

* fix lint

* Fix Lint

* Update qiskit/providers/models/backendproperties.py

Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com>

* Update qiskit/providers/models/backendproperties.py

Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com>

* Update qiskit/providers/models/backendproperties.py

Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com>

* added review changes

* Added release notes

* fixed requested review changes

* Added test for apply_prefix()

* Added newline to the end of file

* Changed operation to gates

* Fix typo and lint

* Added new method frequency(qubit)

* Added frequency to release notes

* Cleaning up

* Added new methods t2(qubit) and readout_error(qubit)

* Typo in docstring

* Fix lint and typos

* Update release note

* Update release note

* Update qiskit/test/mock/fake_openpulse_2q.py

Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com>

* Update qiskit/test/mock/fake_openpulse_2q.py

Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com>

* Typo in docstring

* Update qiskit/providers/models/backendproperties.py

Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com>

* Remove _to_tuple()

* Replaced PulseError with BackendPropertyError
2019-10-21 12:46:45 -04:00
Lauren Capelluto 6cd1a95221 Basic pulse scheduler (#2650)
* Initial commit for issue #1921: basic pulse scheduler

Consolidate language regarding greedy/late scheduling. Small time updating fixup. Do input checking sooner and outside of greedy scheduling

Min early schedule works but needs to be rewritten

Update structure to reflect transpiler/

Update mock CmdDef to work with previous cmd_def tests. Add tests, fixup a couple docstrings

Update mock to use u1, u2, u3. Update tests accordingly and make an expected schedule to compare to

Allow a list of circuits rather than only one circuit for top level `scheduler.schedule`

Update gregs->qubits for accuracy

Wrap cmd_def.get error in helpful message

Allow 'asap' and 'alap' method aliases. Add some comments for alap scheduler. move variables that are used nonlocally in helper functions before the helper function to introduce them to the reader

Allow more input options for schedule (cmd_def and meas_map, all optional)

Change name of cx-parametrized to ParametrizedGate

Use insert rather than union when we probably want to respect the buffer

Add documentation around Measure bug, where qubits aren't measured into the requested memory slot

Update tests for doing insertion schedule building rather than union

Add schedule to top level (from qiskit import schedule)

Fixup imports and move schedule from scheduler to compiler

Fixup tests and changelog (after rebase)

Be more specific in QiskitError import to fix cyclic import warning

Keep circuit name in newly scheduled schedule

ALAP now aligns ends of schedules. Additionally fix bug where qubits not yet seen (in reverse order) wouldn't have their times properly updated when a barrier with that qubit is encountered.

* Make docstring improvements

* Move two scheduling structures to better locations

* Add 3Q test, and 3Q mock to enable such a test. 3Q Pulse mock backend is essentially the same as the 2Q one.

* Style
2019-10-18 17:28:01 -04:00
Ali Javadi-Abhari 17ef10918a Better handling when empty instructions are unrolled or inverse (#3274)
* unroll and inverse empty instructions

* handle unrolling / inversing empty circuits
2019-10-18 15:02:59 -04:00
Kevin Krsulich 5270887cc2
Add initial support for working with ion-trap devices (#3214)
* Add partial transpiler support for targeting ion trap backends. (#3122)

* handle reset/barrier/measure (#3130)

* Do not unroll an Rx,Ry,Rxx circuit to U3,CX because of measure. (#3140)

* rebase ion-trap branch (#3153)

* Remove changelog and document automated creation (#3109)

* Remove changelog and document automated creation

With the introduction of the qiskit-bot release automation for terra we
no longer need to manually maintain or keep a changelog in repo. The
github release pages (which we were manually copy and pasting the
changelog into already) take the place of this file. For all future
releases the creation of this page is completely automatic and handled
by the bot. This works by using the git log and PR tags to figure out
which commits belong in the changelog summary. The commit msg summary
(the first line) is used for the changelog based on the tags. If a
longer explanation is necessary that should be handled in the reno
release notes.

Fixes #3077

* Add README section on changelog

* Make tweaks to readme for clarity

* The option fig.tight_layout is triggering warnings in some situations so it is being removed (#3123)

* no fig.tight_layout

* removing the rest of fig.tight_layout()

* check casteable types in Layout  (#3100)

* test

* cast in insinstance

* style

* layouts are already layouts :)

* Travis CI: The sudo: tag is deprecated on Travis (#3134)

https://blog.travis-ci.com/2018-11-19-required-linux-infrastructure-migration

* Fix a syntax error in QuantumCircuit.mirror. (#3138)

* Fix for #3106 gatefacecolor key on circuit diagrams (#3137)

* Issue #3106 gatefacecolor key has no effect on circuit diagrams

If the style property "gatefacecolor" is set to a different value than the default, this color is applied.

Fixes #3106

* Solved style problem

space before : eliminated

* Update plot_state_hinton() formatting (#3093)

Add axes to the image part. It looks like the image axes already exist for non-empty graphs. The change that I made here is to remove if np.any(dataimag != 0): if the desired behavior is to see the axes on graphs that don't contain any elements.

Replace rho with the latex rho

Use standard format for real and imag parts of rho

Fixes #2321

* Set barrier across multi-qubits correctly (#3042)

* Previously it was assumed that specified barrier has
  a single contiguous span across qubits. Qubits for the
  barrier need not be adjacent in the diagram. This commit
  handles this case by adding barrier across correct qubits.

* compute multiple short spans.

Fixes #2918

* Test pulse clipping fix Osx #1. (#3144)

* Remove superfluous reference to timeslots from assemble_schedules (#3139)

* Extend custom multiqubit gates over classical bits for mpl (#3062)

* Got it to extend over the clasical bits

* Fixed a small bug

* Removed a file accidentally modified

* Fix linter

* Deprecate allowing extra keys in circuit drawer style dict (#3105)

* test

* cast in insinstance

* style

* layouts are already layouts :)

* style['plotbarrier'] is being deprecated

* internal param for text drawer renamed to plot_barriers

* error when style contains unknown options

* better error message

* remove #3100, since it was not my intention to be on it

* style

* remove plotbarrier

* unused import

* replace error with warning

* release note

* rochester_layout (#3125)

* Use _append when args already converted and broadcast. (#2936)

* Remove line in init which had been commented out (#3150)

* Fix circuit drawing justification (#3061)

Fixes #2802

qiskit/visualization/utils.py _get_layered_instructions() was erroneous and did not justify left nor right correctly. I have reworked that code which underlies many visual representations of circuits to the user.

* refactored, needs more work on right justification

* Looks like this works for qiskit-terra issue #2802

* May fix first test failure for this pull request, while causing another?

* Draws conditionals on ClassicalRegister correctly now.

* - Occurs check for gate in gates leads to good test results.
- Added a few more self.maxDiff = None while debugging. Should they be pulled out?

* tabs and trailing spaces ;)

* removed the maxDiff's because they make the Style and lint test in Python 3.5 fail

* added tests
modified changelog

* Test case extended to include original issue reported in #2802

* oops, left a maxDiff=None in from testing. Fixed

* changes to utils.py requested by reviewer maddy-tod

* test cases split as requested by reviewer maddy-tod

* added circuit diagrams in comments to new tests

* removed note from changelog and made it a release note per @mtreinish

* made _LayerSpooler a private class

* Revert "Remove changelog and document automated creation (#3109)"

This reverts commit effad1228e.

* Make _LayerSpooler a subclass of list

The _LayerSpooler class was only ever used as list. While the class was
an independent type it basically just wrapped an internal list. THen
there were helper functions to access and manipulate that list. These
methods just duplicated what python already provides and the list class
itself already implements. This commit fixes this so the _LayerSpooler
itself is a subclass of list so when it's initialized you can just treat
it as the output list it was generating.

* Clean up release note, fix only, not prelude

* un reverted my revert of CONTRIBUTING.md

* refactored, needs more work on right justification

* Looks like this works for qiskit-terra issue #2802

* May fix first test failure for this pull request, while causing another?

* Draws conditionals on ClassicalRegister correctly now.

* - Occurs check for gate in gates leads to good test results.
- Added a few more self.maxDiff = None while debugging. Should they be pulled out?

* tabs and trailing spaces ;)

* removed the maxDiff's because they make the Style and lint test in Python 3.5 fail

* added tests
modified changelog

* Test case extended to include original issue reported in #2802

* oops, left a maxDiff=None in from testing. Fixed

* changes to utils.py requested by reviewer maddy-tod

* test cases split as requested by reviewer maddy-tod

* added circuit diagrams in comments to new tests

* removed note from changelog and made it a release note per @mtreinish

* made _LayerSpooler a private class

* Make _LayerSpooler a subclass of list

The _LayerSpooler class was only ever used as list. While the class was
an independent type it basically just wrapped an internal list. THen
there were helper functions to access and manipulate that list. These
methods just duplicated what python already provides and the list class
itself already implements. This commit fixes this so the _LayerSpooler
itself is a subclass of list so when it's initialized you can just treat
it as the output list it was generating.

* Clean up release note, fix only, not prelude

* put back missing section

* Add partial transpiler support for targeting ion trap backends. (#3122)

* handle reset/barrier/measure (#3130)

* Do not unroll an Rx,Ry,Rxx circuit to U3,CX because of measure. (#3140)

* Add global Molmer-Sorenson gate (#3149)

* add global ms gate

* clean up

* Update qiskit/extensions/standard/ms.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* Update qiskit/extensions/standard/ms.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* clean up

* Update qiskit/extensions/standard/ms.py

Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com>

* Update MS docstring
2019-10-11 11:30:14 -04:00
Ali Javadi-Abhari 51dfa28383 fix and add mock backend properties (#3226)
* update pok props

* add almaden, johannesburg, singapore, vigo

* add to __init

* expand randomized testing

* lint
2019-10-09 10:18:47 -04:00
Luciano 3383d16041 remove disable=invalid-name in test/python/test_dagcircuit.py (#3221) 2019-10-08 09:25:45 -04:00
Ali Javadi-Abhari 1cb65623b4 Cleanup inst control usage from source tree (#3198)
* remove deprecated code from source

* cleaning up more

* remove error
2019-10-07 14:52:49 -04:00
drholmie 4b71d63806 Added tests for definitions of cswap, cu1, cu3, cx (#3182)
Partially fixes #2964
Added in tests for cswap, cu1, cu3 and cx under test_gate_definitions
2019-10-07 09:41:07 -04:00
Luciano a934b1f948
Add new passmanager.replace(index, ...) method (#3004)
* replace method

* error handle

* lint

* changelog

* lint

* release note

* key->index

* error message

* lint

* release note

* iamges

* replace images for text
2019-10-04 21:02:24 -04:00
Matt-Stypulkoski 7ac8f892b0 Add measure_all, measure_active, remove_final_measures methods (#2993)
* Add measure_all, measure_active, remove_final_measurement methods

* Add testing for measure_all, measure_active, remove_final_measurements

* Rename remove_final_measurements to remove_final_measures

* Rename test_remove_final_measurements to test_remove_final_measures

* Fix incorrect method call in test_remove_final_measures

* Fix remove_final_measures to only delete ClassicalRegister if it is unused. Fix measure_active to only check for non-idle qubits instead of  non-idle qubits and clbits

* Add test_remove_final_measures_multiple_measures

* Remove 'gates' from docstrings when referring to measurements

* Rename remove_final_measures to remove_final_measurements

* Rework remove_final_measurements to use RemoveFinalMeasurements pass

* Add RemoveFinalMeasurements pass

* Add remove_final_measurements module

* Rework test_remove_final_measurements_multiple_measures to work with new circuit.remove_final_measurements

* Add pylint disable-cyclic-import to remove_final_measurements

* tests

* fix test

* test to avoid name conflict

* avoid code repetition

* Add QuantumCircuit methods to add and remove final measurements

* Add newline at end of file

* Change inst.control to inst.condition
2019-10-04 14:33:57 -04:00
ewinston ef828be2c7 add instruction.control deprecation release notes (#3188) 2019-10-04 14:03:44 -04:00
Luciano 654c3a92ba Add float exponentiation for Gates (#2811)
* from unittest.mock import patch

* .

* positive power of standard gate

* one and zero

* minus one

* inverse

* docstring and test

* sqrt

* standard

* linting

* docstring

* docstring

* pylint: disable=cyclic-import

* unroller

* power(0)->u3(0,0,0)

* Update qiskit/circuit/instruction.py

* lint

* Implement general power of Gate

By asserting that a gate is Unitary we can diagonalize it and easily
compute powers of the gate.

* cyclic-import

* docstring

* disable

* sqrt test

* sqrt

* improve testing

* delete old tests

* refactor variable names

* docstrings

* power returns an instruction always

* line too long

* lint

* cyclic import

* test

* fix

* Update qiskit/circuit/instruction.py

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>

* docstring

* test with (-1,1) range

* improve test

* from numpy.linalg import matrix_power

* categories in gates

* test_measure

* measure -1

* return a gate when operating in a gate

* SGate().to_matrix() is diagonal so `**` is equivalent.

* TestPowerInvariant

* (op^(1/n))^(n) == op

* (op^(1/n))^(n) == op, integer n

* lint

* other invariant test

* simplification!

* import

* setting the label instead of the name

* readjust test.python.circuit.test_gate_power.TestPowerInt2Q

* docstring

* clean import

* adapted tests

* simpler complex

* Update test/python/circuit/test_gate_power.py

Co-Authored-By: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>

* ddt in test_sgate_float

* test_invariant1_int

* TestPowerIntCX with ddt

* move test_zero_two to ddt

* unused inmports

* check

* docstring
2019-10-04 11:47:32 -04:00
Paul Nation bae322f0d6 DenseLayout is noise-aware
* initial_checkin

* make level 2 dense noise adaptive

* unused import

* make simpiler

* fix no cx or meas

* fix empty circ

* fix test

* remove text

* apply suggestions

* formating the test file

* release note
2019-10-03 14:30:20 -04:00
Lauren Capelluto 7b5d8ceb65 Add version method to backend, mirroring 'name', and add basic tests (#3165) 2019-10-02 15:46:18 -04:00
ewinston 535c68ad6f Add negation support for Parameter class. (#3148)
* add negation support for Parameter

* add test explicitly of form in issue 3098.
2019-10-01 14:03:21 -04:00
nkanazawa 5ee0d2496c Add memory_slots to pulse experimental header (#3048)
* add memory_slots to experimental header

* add schedule independent memory slots and common memory slots in qobj config

* remove schedule import

* fix tmp memory slot size

* add test for schedules with different memory slot sizes

* add reno
2019-10-01 11:05:08 -04:00
Kevin Krsulich efef748717
Update CX direction pass to modify input DAG in-place. (#3173) 2019-09-30 16:55:41 -04:00
Kevin Krsulich 0e39b19542 Add DAGCircuit.substitute_node for single node replacement. (#3145)
* Add DAGCircuit.substitute_node function.

* Add DAGCircuit-multi_graph consistency check.

* Add inplace option to DAGCircuit.substitute_node.

* Deprecate DAGNode.pop().

* Move dagcircuit validation to test file.
2019-09-27 14:56:57 -04:00
Lauren Capelluto 0b197d1fe4 Move pulse utils to reschedule (#3154)
* Move pulse utils, which are Schedule -> Schedule functions, to a reschedule file

* Raise helpful warning

* Style

* Ignore style warning for unused imports, because the functions aren't being called, they are only raising warnings for the user
2019-09-27 12:07:24 -04:00
Jack J. Woehr 7a51637d27 Fix circuit drawing justification (#3061)
Fixes #2802

qiskit/visualization/utils.py _get_layered_instructions() was erroneous and did not justify left nor right correctly. I have reworked that code which underlies many visual representations of circuits to the user.

* refactored, needs more work on right justification

* Looks like this works for qiskit-terra issue #2802

* May fix first test failure for this pull request, while causing another?

* Draws conditionals on ClassicalRegister correctly now.

* - Occurs check for gate in gates leads to good test results.
- Added a few more self.maxDiff = None while debugging. Should they be pulled out?

* tabs and trailing spaces ;)

* removed the maxDiff's because they make the Style and lint test in Python 3.5 fail

* added tests
modified changelog

* Test case extended to include original issue reported in #2802

* oops, left a maxDiff=None in from testing. Fixed

* changes to utils.py requested by reviewer maddy-tod

* test cases split as requested by reviewer maddy-tod

* added circuit diagrams in comments to new tests

* removed note from changelog and made it a release note per @mtreinish

* made _LayerSpooler a private class

* Revert "Remove changelog and document automated creation (#3109)"

This reverts commit effad1228e.

* Make _LayerSpooler a subclass of list

The _LayerSpooler class was only ever used as list. While the class was
an independent type it basically just wrapped an internal list. THen
there were helper functions to access and manipulate that list. These
methods just duplicated what python already provides and the list class
itself already implements. This commit fixes this so the _LayerSpooler
itself is a subclass of list so when it's initialized you can just treat
it as the output list it was generating.

* Clean up release note, fix only, not prelude

* un reverted my revert of CONTRIBUTING.md

* refactored, needs more work on right justification

* Looks like this works for qiskit-terra issue #2802

* May fix first test failure for this pull request, while causing another?

* Draws conditionals on ClassicalRegister correctly now.

* - Occurs check for gate in gates leads to good test results.
- Added a few more self.maxDiff = None while debugging. Should they be pulled out?

* tabs and trailing spaces ;)

* removed the maxDiff's because they make the Style and lint test in Python 3.5 fail

* added tests
modified changelog

* Test case extended to include original issue reported in #2802

* oops, left a maxDiff=None in from testing. Fixed

* changes to utils.py requested by reviewer maddy-tod

* test cases split as requested by reviewer maddy-tod

* added circuit diagrams in comments to new tests

* removed note from changelog and made it a release note per @mtreinish

* made _LayerSpooler a private class

* Make _LayerSpooler a subclass of list

The _LayerSpooler class was only ever used as list. While the class was
an independent type it basically just wrapped an internal list. THen
there were helper functions to access and manipulate that list. These
methods just duplicated what python already provides and the list class
itself already implements. This commit fixes this so the _LayerSpooler
itself is a subclass of list so when it's initialized you can just treat
it as the output list it was generating.

* Clean up release note, fix only, not prelude

* put back missing section
2019-09-26 09:03:41 -04:00
Luciano 49a4295f62
Deprecate allowing extra keys in circuit drawer style dict (#3105)
* test

* cast in insinstance

* style

* layouts are already layouts :)

* style['plotbarrier'] is being deprecated

* internal param for text drawer renamed to plot_barriers

* error when style contains unknown options

* better error message

* remove #3100, since it was not my intention to be on it

* style

* remove plotbarrier

* unused import

* replace error with warning

* release note
2019-09-25 15:04:42 -04:00
Kevin Krsulich 0a7f0462f7 Fix a syntax error in QuantumCircuit.mirror. (#3138) 2019-09-24 13:37:35 -04:00
Luciano f9dee61dbb check casteable types in Layout (#3100)
* test

* cast in insinstance

* style

* layouts are already layouts :)
2019-09-24 09:38:51 -04:00
Christopher J. Wood 5195991ac9 add rxx gate (#3113)
Co-authored-by: ma5x <max.hettrich@aqt.eu>
Co-authored-by: strickroman <strickroman@gmail.com>
2019-09-19 13:16:59 -04:00
Matthew Treinish 1cf95cce80 Validate input when setting the QuantumCircuit data attribute directly (#2838)
* Deprecate setting the QuatumCircuit data attribute directly

This commit deprecates setting a QuantumCircuit's data attribute
directly. Accessing and reading it are not deprecating, just directly
changing it's value outside of the circuits API.

Fixes #2826

* Update changelog

* POC Proxy interface for circuit.data.

* Implement CircuitData as MutableSequence and add tests.

* Correct bad merge resolution.

* Remove unused imports and lint.

* Update pickles

* Add release notes

* Update CHANGELOG.md

Co-Authored-By: Luciano <luciano.bello@ibm.com>

* Update qiskit/circuit/quantumcircuitdata.py

Co-Authored-By: Luciano <luciano.bello@ibm.com>
2019-09-19 12:28:56 -04:00
Christopher J. Wood 47d346d18b One qubit Euler basis decomposer (#3115)
* add custom euler angle decomposition

* improve accuracy for ZYZ euler synthesis

* Use old euler_angle_1q method for ZYZ so we don't need quaternions
* XYX converts ZYZ to quaternions then to the new basis

* add 1q synthesis tests

* merge synthesis tests

* verify synthesised unitary

* LINTERLIFE
2019-09-19 11:28:15 -04:00
nkanazawa 31e0d8c6cf Fix pulse drawer bug for truncating Acquire command (#3091)
Truncation for Acquire command is not properly implemented. Pulse drawer crashes when we try to truncate Acquire command with plot_range option. In this PR, pulse length of Acquire is adjusted to fit in with specified plot range.

Fix #3076

* truncate acquire pulse

* add unittest
2019-09-18 11:53:21 -04:00
Ali Javadi-Abhari 542ced314c add snapshot of real calibration data to mock backends (#3060)
* add a snapshot of device properties to mock backends

changelog

release note

update location

update loc

rm jo

rm

rm

update backend files

* fix noise adaptive layout test
2019-09-17 10:42:21 -04:00
Luciano 326a35bfeb Deprecate Bit-tuple equality check (#3040)
* deprecate Bit-tuple equality check

* tuples for bits!

* do not altern the topological order

* removing deprecation

* removing more deprecation

* removing even more deprecation

* release note

* changelog
2019-09-16 09:28:32 -04:00
ewinston 78b4769fa1 fixes ParameterTable for instructions inserted more than once (closes #3014) (#3079)
* add issue-based test

* converted ParameterTable element from list to set.

* went back to list in parameter table.

* revert quick fix from pr #3013
2019-09-16 08:06:25 -04:00
drholmie 2b2e8eb833 Added tests for definitions of gates ccx and crz (#3065)
Partially fixes #2964
Updated CHANGELOG
2019-09-09 11:38:49 -04:00
Thomas Alexander f62e9a4779 Add scheduling padding method (#2880)
* Added delay command and instruction.

* Added delay to __init__.

* Add delay to schedule assembly

* Add delay too init.

* Add delay too init.

* Split up schedule tests.

* rename command tests.

* Add discriminator test.

* Add delay tests for pulse channels.

* Add pulse schedule delay tests.

* Add conversion method for delay.

* Add delay assembly test.

* Add delay to plot test.

* Add delay docstring.

* Update changelog with delay instruction.

* Added docstrings for delay.

* Linting.

* fix: delay comments.
fix: pulse visualization test removal of file command that was removed.
fix: cleaned up pulse tests.

* Make delay instruction handling more explicit.

* Fix conflict error.

* Add delay to schedule assembly

* Modified timeslots to perform more efficient insertions.

* Modified timeslots to perform more efficient insertions.

* Reorder functions.

* Reset util.

* Redefine intervals by start and stop rather than begin and end.

* Redefine intervals by start and stop rather than begin and end.

* Updated changelog.

* Split up schedule tests.

* rename command tests.

* Update changelog with delay instruction.

* Begin adding complement TimeslotCollection method.

* Added complement method to TimeslotCollection.

* Padded out padding method.

* Update pad test.

* Fix pad test.

* Linting and test updates.

* linting.

* Remove duplicate changelog entry for delay.

* Remove helper method.

* update pad docstring.

* fix bad if statement return in timeslots.'

* Linting.

* Add print statement for azure testing.

* Additional print debug.

* Updated debug.

* Another one

* Updated instruction representation.

* Print update.

* debug print statement.

* Print statement.

* Fix bug in complement timeslot generation.

* Added a reno for pad.

* Update padding reno

* Update pulse init.

* Remove init modificiations of pulse.

* Update releasenotes/notes/schedule-pad-method-a56c952fcfdfbf08.yaml

Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com>

* Update reno with pulse instead of delay.
2019-09-06 14:28:28 -04:00
Ali Javadi-Abhari be9b0da397 Split mock backends and add new ones (#3050)
* split files for backend mock utilities

* fix coupling maps of new devices

* copyright year

* fake qobj docstring

* graphs with direction

* ourense

* FakePoughkeepsie

* asciiart
2019-08-28 14:35:57 +02:00
Luciano 61656e340a CI should run with mpl backend = ps (#2949)
* new reference files

* drop the not matching files

* inputs

* linux and mac

* another one fails

* new ref file

* do not save

* do not remove

* windows

* different refs for different os

* shorter lines

* remove ref

* new refernces

* udpate ref

* clean the azure conf

* moving the env to Makefile

* azure results

* ref image

* make test_ci

* at import time

* the other test

* clean up and new ref

* save for windows

* new ref

* clean up azure conf

* removing backend selection in qiskit/visualization/matplotlib.py

* add backend selection in testing

* lint

* tight

* backend in ci

* .

* drop

* do not remove and copy

* copy results

* save everything

* new ref

* skip these tests if matplotlib is not installed

* TestGraphDist only if HAS_MATPLOTLIB

* lint

* only under failing condition

* new ref

* rest of the artifacts

* Update azure-pipelines.yml

* twice in the same job

* Fix stray whitespace yaml syntax issue

* display name
2019-08-27 17:38:32 -04:00
Ali Javadi-Abhari 7457aa9fad
Fix mpl conditional drawing (#3032)
* fix conditional drawing in mpl

* changelog

* add ref image

* lint
2019-08-27 12:02:33 -04:00
Matthew Treinish f54f02d151 Make graphviz availability check at runtime (#3041)
Previously the graphivz availablity check was performed at import time.
This meant that everytime anyone imported anything from qiskit.* we'd be
shelling out to try and run 'dot -V' to see if python could find
graphviz in order to run the passmanager drawer. This was based on the
model we used for matplotlib which also does it at import time. However,
unlike matplotlib this isn't a simple python import path check shelling
out and running another program takes a non-negligble amount of time to
any import of qiskit. [1] We shouldn't force this check to run all the
time if graphviz is only needed when running the pass manager
visualizer. This commit address this by switching the graphviz check to
be the first operation that occurs in the pass_manager_drawer() function
instead of at the module level. There is no change in behavior except
for when the check is run. However, since this check was used for
testing and is needed to occur at import time for the test module the
check is duplicated in the test code to ensure we can properly skip
tests if graphviz is not present.

[1] https://qiskit.github.io/qiskit/#import.QiskitImport.time_qiskit_import?commits=2d14c1e3
2019-08-26 20:29:45 +02:00
Lauren Capelluto f22a937a5e Remove deprecated device specs (2 months ago) (#3033)
* Remove deprecated code (2 months ago)

* Remove unused imports

* Update CHANGELOG and release notes

* Add note that device specs was deprecated
2019-08-26 14:06:46 -04:00
Luciano 41dfef9437 No random in test_circuit_properties (#2930)
* from unittest.mock import patch

* .

* remove random in test_circuit_properties

* unsed import
2019-08-24 10:16:39 -04:00
Ali Javadi-Abhari 10a0678700
Shorter controlled-hadamard definition (#2837)
* shorter CH gate definition

* changelog

* add ch matrix

* import numpy

* add test

* fix broken test
2019-08-21 22:19:53 -04:00
Luciano 40861074c5 if passmanager.draw(raw=true), do not create the png (#3022)
* if raw, do not create the png

* exception

* docstring

* different exception
2019-08-21 18:01:59 -04:00
Kevin Krsulich 1e24d40cd9 Deepcopy all but first instruction when broadcasting. (#3013) 2019-08-21 10:54:40 -04:00
Thomas Alexander 35d47af838 Add delay instruction (#2869)
* Added delay command and instruction.

* Added delay to __init__.

* Add delay to schedule assembly

* Add delay too init.

* Add delay too init.

* Split up schedule tests.

* rename command tests.

* Add discriminator test.

* Add delay tests for pulse channels.

* Add pulse schedule delay tests.

* Add conversion method for delay.

* Add delay assembly test.

* Add delay to plot test.

* Add delay docstring.

* Update changelog with delay instruction.

* Added docstrings for delay.

* Linting.

* fix: delay comments.
fix: pulse visualization test removal of file command that was removed.
fix: cleaned up pulse tests.

* Make delay instruction handling more explicit.

* Fix conflict error.
2019-08-20 11:09:20 -04:00
Luciano 7cfc94cb18 Text drawer supports composite gates with both quantum and classical wires (#2997)
* fix the exception text

* new _set_multibox API

* box shape

* harness to length

* centering the label

* centering!

* lint
2019-08-19 11:47:09 -04:00
Lauren Capelluto 752b94ab5d Issue 2848 improve schedule performance (#2995)
* Modified timeslots to perform more efficient insertions.

* Reorder functions.

* Reset util.

* Redefine intervals by start and stop rather than begin and end.

* Update docstrings of timeslots.

* Add interval methods to timeslot.

* Update methods to use new timeslot methods rather than underlying interval methods.

* linting.

* Localize timeslotcollection try statement.

* Change dumb way of returning booleans.

* Improve locality check.

* fix bubble vs insertion sort comment

* Remove le,ge and starts_after and stops_after methods.

* Change timeslot collection merging to not use sets.

* Update mergeable method.

* Readd channel start and stop at 0 if no instructions are present

* Simplify logic in _merge_timeslot_collection

* Fix bug: cant set timeslots, need to copy them
2019-08-15 21:40:30 -04:00
Maddy Tod 37ef208e4b Updated so that all DAG pred/succ functions return iterators (#2917)
* Updated so that all pred/succ functions return iterators

* Updated more types in the DAG so that they now use Bits
2019-08-14 15:13:44 -04:00
Paul Nation aad92ea7ed Make jupyter progressbar line magic (#2954)
* progressbar to line magic

* updates
2019-08-14 13:52:47 -04:00
Thomas Alexander 326be30c41
Clip pulse samples if within epsilon unit norm (#2796)
* Add samplepulse testing.

* Add test for sample norms.

* Added clipping of pulses if norm slightly exceeds 1.

* Updated changelog.

* linting.

* clip by angle instead of epsilon.
2019-08-14 13:22:59 -04:00
Kevin Krsulich bb2ea373b2 Change Parameter equality from python id() to internal uuid(). (#2947)
Parameters were defined such that they would only ever __eq__ self. That way, 
if a user defined a Parameter('theta') and wanted to compose in a subcircuit 
defined elsewhere which contained a different Parameter('theta'), we would 
be able to detect that the parameter names overlapped and raise an error.

However, if a user sent a Parameter to a different python instance though (say
 through multiprocessing.Pool or qiskit.tools.parallel_map), it would be
instantiated as a different python object and so no longer be considered equal
to the original parameter.

This PR changes Parameter to instead generate a random UUID on
instantiation and use that for equality testing. Unlike id(self), self._uuid will be
preserved across pickling and de-pickling, but should otherwise preserve
Parameter's equality behavior.

Fixes #2429
Fixes #2864
2019-08-14 12:53:08 -04:00
Thomas Alexander 87de2755eb Add pulse instruction and schedule equality testing (#2873)
This adds pulse instruction and schedule equality testing. This will make writing Schedule tests easier.

I also added a small change to return instructions with a fixed ordering. This was required for the initial way I implemented equality testing, but have since refactored so that it is not necessary. 

Instruction testing verifies that the lhs and rhs have the same Command on the same channels.

Schedule testing first ensures that the lhs and rhs each have the same channels and the same number of instructions. Then it verifies that each instruction at each time in the rhs is contained within the rhs.

* Add schedule and instruction equality testing.

* Modify equality check to be more straight forward.

* Updated changelog.

* refactor equality checking of Commands to not check name and also use the super class of eq.

* Update qiskit/pulse/commands/command.py

Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com>

* Fix unpythonic equality checks.

* Add proper hashes for commands.

* Update test/python/pulse/test_schedule.py

Co-Authored-By: Lauren Capelluto <laurencapelluto@gmail.com>

* Change equality check to be based on position in .
2019-08-14 10:16:32 -04:00
Thomas Alexander 453c69f8d8 Add more informative errors missing qubit and measurement los (#2833)
This PR adds more informative errors of qubit_lo_freq and meas_lo_freq are missing. A set of tests are added other assemble_schedule optional kwargs to ensure the desired behaviour.

As a follow-up #2832 has been raised to discuss a better lo interface.

Closes #2547

* Add tests for kwargs in assemble schedules. Make qubit_lo_freq and meas_lo_freq raise errors if not supplied.

* Error is now raised for missing qubit and measurement los.

* Added additional missing assemble kwarg tests.

* Change test assertion.

* Update changelog.

* linting.

* Fix lo range checking in lo_config.

* update memory slot assembly test.

* Fix merge bug.
2019-08-13 19:44:27 -04:00
Luciano 98141a02e1 Use TrivialLayout in optimization level 1 (#2975)
This reverts #2971

* Use TrivialLayout in optimization level 1

* lint

* typo
2019-08-13 19:25:35 -04:00
Luciano a2d1d412c0 Support for circuit.layout in the drawers (all of them) (#2781)
Fixes #2739

This PR adds layout support for all the drawers, with the option with_layout=bool.

* from unittest.mock import patch

* .

* util

* options

* docstring

* text

* done with text

* more tests

* remove utils function

* mpl

* remove namedtuple

* mpl

* latex

* lint

* flip order

* space in latex

* utils

* lint

* layout -> _layout

* Revert "layout -> _layout"

This reverts commit 576c243784.

* layout -> _layout

* merge

* CHANGELOG

* flip layout

* default is True, so no need to have arg

* new test

* changelog

* fixing text

* adjust tests

* fixing latex

* fix mpl

* add test

* name classical register

* __str__

* single_line

* optimization_level

* print result

* avoid paging
2019-08-13 15:52:44 -04:00
Diego M. Rodríguez 79777e9370 Rename circuit.diagGate to diag_gate (#2963) 2019-08-13 12:35:48 -04:00
Thomas Alexander 07d54eda16 Moved samplers module into pulse.pulse_lib.samplers (#2881) 2019-08-13 12:04:02 -04:00
Luciano b5d15118ae Plot circuit layout test (#2929)
* from unittest.mock import patch

* .

* layout -> _layout

* qiskit/visualization/gate_map.py

* add a test for plot_circuit_layout

* increase tolerance

* keep the file

* artifact

* comment out other builds

* put it back

* remove jobs

* jobs back

* task

* first one seems to work!

* back to the tests

* backend[1]

* [2]

* [3]

* azure-pipelines

* do not remove

* results

* artifact

* copy

* other job

* condition

* no windows job

* condition

* copy

* specific test

* content

* monospace

* label

* extend automatically the layout

* plt.rcParams

* new references

* backend

* linting

* backend for windows
2019-08-13 11:25:48 -04:00
Luciano 109d8ea562
Use DenseLayout in optimization level 1 (#2971)
* use denselayout in level 1

* readjust tests

* CHANGELOG

* lint

* import order
2019-08-13 07:38:29 -04:00
Maddy Tod 06cf589f23 Fixed ConsolidateBlocks over multiple registers (#2931)
Fixes #2806

The issue was the way registers were being indexed in the pass. Previously, the overall index of a qubit was overall_index_of_reg + index_of_wire_in_reg. This became an issue when the registers had a size larger than 1.

For example,

 qr0 = QuantumRegister(2, "qr0")
 qr1 = QuantumRegister(1, "qr1") 

would lead to a global list of registers [qr0, qr1]. This would then index the qubits using the above formula as

qr0[0] = 0 + 0 = 0
qr0[1] = 0 + 1 = 1
qr1[0] = 1 + 0 = 1

As you can see this means there are 2 qubits with the overall index of 1 and so when a CX gate was applied between these 2 it appeared to be applied to the same qubit twice, the qubit at index  1.

I fixed this by updating the way the index was calculated.
It is now sum_of_all_prev_reg_sizes + index_of_wire_in_reg

* Updated the way the registers are indexed so that there are no longer duplications

* Updated the testing

* Fixed the testing to compare the unitary gates each circuit produces to check they are equal

* Removed comments left in

* Implemented suggested change from review - much tidier!

* Fixed linter error
2019-08-12 12:54:04 -04:00
Maddy Tod 5303420daa Fixed block collection with classical conditions in Collect2QBlocks (#2956)
* Updated calls to be the quantum versions

* Added in a test case

* Fixed linting
2019-08-12 09:48:59 -04:00
Luciano 51992588b4
replacing self.assertTrue(numpy.allclose()) by numpy.assert_allclose in tests (#2924)
* from unittest.mock import patch

* .

* shorter test/python/test_dagcircuit.py

* shorter test/python/test_dagcircuit.py

* test.python.quantum_info.test_weyl

* test.python.quantum_info.states.test_statevector

* test/python/quantum_info/states/test_densitymatrix.py

* test.python.quantum_info.test_quaternions

* test.python.quantum_info.test_local_invariance
/

* test.python.circuit.test_unitary

* test.python.quantum_info.operators.test_operator

* test.python.quantum_info.operators.channel.test_chi

* test/python/quantum_info/operators/channel/test_superop.py

* test/python/quantum_info/operators/channel/test_choi.py

* test/python/quantum_info/operators/channel/test_evolve.py

* test/python/quantum_info/operators/channel

* lint

* unused import

* atol TestWeyl
2019-08-08 18:45:56 -04:00
Kevin Krsulich 5aaf6e7b5b Add ParameterExpression class supporting basic Parameter math. (#2537)
* Add ParameterExpression class supporting basic Parameter math.

* Consistently return ParameterExpressions, even when fully bound.

* Add ParameterExpression support to transpiler passes.

* ParameterExpression tests for instruction equality and converters.

* Add ParameterExpression tests for transpiler and assembler.

* Add ParameterExpression to qobj parameter validation.

* cast for __eq__

* Revert "cast for __eq__"

This reverts commit 8e0c650f4f.
2019-08-08 16:57:54 -04:00
Maddy Tod 1b06e321e1 ConsolidateBlocks keeps classical conditions (#2934)
* Added in the condition when adding nodes to the DAG

* Found another missing condition

* fixed a typo
2019-08-08 11:17:04 -04:00
Maddy Tod 64f4c1d23b Removed a test file that shouldn't have been left in (#2943)
In #2505 an output of a test was accidentally left in and as the tests are no longer running it won't be automatically removed. This commit removes it.
2019-08-08 06:52:09 -04:00
Paul Nation ec1f557424
MPL drawer to match IQX with IBM design colors (#2505)
* color updates

* more style

* remove file

* updates

* fix inversion of target colors in bw mode

* lint

* make color setting easier

* color fix

* fixed ref images

* fix

* skip tests that can not be satisfied

* better styling

* lint

* fix cswap edge color

* update images

* update colors

* fix zorder of register lines vs gate lines

* fix skip reasons

* color multi-q gates same as other non-grouped gates

* fix style=False
2019-08-08 05:05:19 -04:00
Luciano cfc96db0fa
Run CheckCXDirection and CXDirection only in case of asymmetric coupling map (#2883)
* from unittest.mock import patch

* .

* CheckCXDirection

* more testing

* lint
2019-08-07 13:03:13 -04:00
Luciano 72b4878e50
circuit.layout -> circuit._layout (#2928)
* from unittest.mock import patch

* .

* layout -> _layout

* qiskit/visualization/gate_map.py
2019-08-07 12:22:45 -04:00
Quintiii 84f1e19a15 added n_qubit funtionality and test (#2909)
* added n_qubit funtionality and test

* tests moved to circuit properties test file

* added tests to test_circuit_properties.py file and deleted the previous redundant test file

* Fixing method calling issue and updated qubitless circuit test
2019-08-07 05:37:53 -04:00
Paul Nation 472ae49be3
Ordered count_ops (#2926)
* ordered count_ops

* docstring update

* test

* lint

* changelog
2019-08-07 04:40:17 -04:00
nkanazawa 8c9899f30a Fix memory_slots number bug in pulse assembler (#2920)
* add unittest

* overwrite wrong test

* fix index bug

* minor change

* update test
2019-08-06 20:16:45 -04:00
Paul Nation 74dba0ac57
Jupyter version table and copyright (#2791)
* add version table

* remove backend_monitor magic code

* updates

* add display

* fix lint

* merge copyright in

* updates
2019-08-06 13:21:57 -04:00
Luciano b970a21796 instruction.repeat (#2901)
* from unittest.mock import patch

* .

* moving from a different branch to master

* clean up import

* style
2019-08-06 11:46:28 -04:00
Maddy Tod fa72ba6640 Fixed ConsolidateBlocks to add the block in the correct place (#2764)
* fixed consolidate blocks to add the block in the correct place

* Updated how consolidating blocks works and added in a test

* Changed a comment into an error

* Made the comments on the tests more descriptive and updated a list to be a set

* Fixed the collect2qblocks pass to work if there are gates in the middle of a block
2019-08-06 11:26:10 -04:00
Christopher J. Wood 86fb7f95a4 Add equiv method to Operator and Statevector classes (#2910)
* add Statevector, DensityMatrix classes to quantum_info init

* add equiv method to Operator

* Checks if two operators are equivalent up to global phase

* return false rather than raise in equiv

* add Operator.equiv test

* add equiv method to Statevector

* update changelog

* mr lint
2019-08-06 10:38:32 -04:00
Matthew Treinish 56b0f672dc Use stdlib python logging for pass manager logging (#2782)
* Use stdlib python logging for pass manager logging

This commit reworks the pass manager logger to use python stdlib logging
instead of attributes in the Passmanager class. This will enable users
to use standard logging mechanism and capture to access debug messages
from the pass manager.

* Fix lint

* More Lint

* Fix lint

* Add log_level option to transpile()

* Fix lint and tests
2019-08-06 10:00:21 -04:00
Luciano e303e64e9c Follow up to output_name parameter in transpiler (#2890)
* from unittest.mock import patch

* .

* https://github.com/Qiskit/qiskit-terra/pull/2789#discussion_r309255704

* docstring

* output_names -> output_name

* TranspileConfig

* CHANGELOg

* None output_name
2019-08-06 09:45:12 -04:00
Matthew Treinish d5117c06fe Make azure pipeline steps fail on intermediate commands (#2905)
* Make azure pipeline steps fail on intermediate commands

The azure pipelines commands were previously using the script directive
which on windows uses cmd.exe to run commands. The return code for the
step process only returns non-zero and exits if the last command in the
script returns non-zero, it will continue running if an intermediate
command fails. This can lead to hard to parse errors because something
failed earlier in the pipeline and we don't catch it until later. For
example pip install stestr failing because of a network issues and then
we get a command not found error when we go to run tests. This commit
fixes this issue by switching all the scripts to explicitly use bash
and then using 'set -e' to set errexit to make sure any failing
command causes the job to fail there.

Related to #2879

* Skip failing visualization comparison check on windows

* See if current stestr master fixes the weird osx failure

* Disable streaming output and summary for MacOS

For some reason that I'm not sure about the timestamps for at least one
test are being set to None by the underlying stdlib unittest test runner
in MacOS (instead of a date). This is breaking some of the formatting
used by stestr to provide information about how it's running in
parallel. There is a fix pending in stestr to address this case, but I
suspect something else is causing this which will also need to be fixed.

* Run stestr failing to get failing test name

* Decrease MacOS Job concurrency

* Remove concurrency limit on macos

* Add debug stage to osx to collect system info

* Always run debug stage on macos

* sudo dmesg on macos

* Add more macos debug info

* Downgrade macOS and decrease concurrency
2019-08-05 11:37:39 -04:00
Kevin Krsulich ac905f960d
Add __init__ to test/randomized directory and fix missing import. (#2898) 2019-08-02 15:14:51 -04:00