Commit Graph

1168 Commits

Author SHA1 Message Date
Ali Javadi-Abhari 6086dbf1a9 Coupling map constructors (#3618)
* simple coupling map constructors

* release note

* add tests

* compare set of edges instead of list
2019-12-18 22:21:47 +00:00
neupat 64e5eef979 Add Crx and Cry gates (#3600)
* add tests

* fix docstring of crx

* fix Rotation.control() function

* fix add_control

* fix test_unroller.py

* fix test_unroller and circuit_text_ref.txt drawing
2019-12-18 13:18:22 -05:00
Luciano Bello 9c140b4894 Setting limits for CSPLayout (#3515)
* limit in the solver

* cleaning up

* lint

* add no limit for call_limit=None

* add time limit

* adding reason to stop

* but on reason

* limit tests

* remove qasm

* docstring

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

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

* rename the property CSP_stop_reason

* release notes
2019-12-16 17:01:55 -05:00
Ali Javadi-Abhari 06e56a900e add zxz decomposition (#3519) 2019-12-13 09:25:47 -05:00
Matthew Treinish f17f8f073e Add python 3.8 support and deprecate python 3.5 (#3268)
* Add python 3.8 support and deprecate python 3.5

This commit adds support for running terra under python 3.8. It does
this by adding the trove classifiers to the package metadata and adding
a test job for python 3.8 (only travis for now this can be expanded in
the future when azure pipelines adds it to their image). At the same
time this commit starts the deprecation window for python 3.5. Python
3.5 goes end of life by upstream python in Sept. 2020. We should give
our users running with python 3.5 (which is about 10% of our users based
on pypi data) fair notice that when upstream python stops supporting it
we do as well.

* Fix lint

* Add back empty cache detection

As part of the refactors the empty stestr timing cache removal code was
removed from the travis config, but the cache wasn't removed. Adding the
python 3.8 job causes a failure because travis has no cached timing data
but still creates the empty directory which triggers
mtreinish/stestr#266. This adds back the empty cache removal to
workaround it so we can use the timing data for scheduling in future
runs.

* Add azure-pipelines python 3.8 jobs too

* Fix python 3.8 dictionary keys changed error

Starting in python 3.8 a new RuntimeError is raised, RuntimeError:
dictionary keys changed during iteration. This is caused by modifying an
iterator while looping over it. We were doing that in the
optimize_swap_before_measure pass. This commit fixes this by wrapping
the iterator in list() to make a copy of it for looping. This way we
don't modify the contents of what we're iterating over in the pass.

* Revert "Add azure-pipelines python 3.8 jobs too"

The missing matplotlib wheels are blockers for windows and osx
environment. Since we do not have the necessary dependencies installed
in those ci envs to compile matplotlib from source. We'll rely on just
travis for 3.8 testing until the matplotlib 3.2.0 release is pushed so
we don't have to compile it.

This reverts commit 40157621b1.

* Add skip for failing matplotlib test

The image comparison tests which are quite flaky are failing with
matplotlib compiled on 3.8. Looking at the image output from these
failures are very subtle (looks like resolution differences) again
questioning the value of these tests. This commit just skips the test
that is failing here to unblock the PR.

* Add azure 3.8 test jobs

* Pin to pre-release mpl for python 3.8

* Add spawn guard for python3.8 osx in examples

When running examples with execute, transpile, or any other calls using
parallel_map() the new default for spawn instead of fork requires that
scripts have a __name__ == "__main__" check in them to function
properly. If not calls to parallel_map fail errors around the
bootstrapping phase. To avoid this in the ci jobs this commit adds the
necessary checks to the example scripts we run in ci as part of
test_examples.

* Remove cryptography pin from constraints file

We pinned the cryptography package version back during the cryptography
2.6 release which broke our ci. It was a temporary step to avoid a
packaging issue in CI that was blocking development. However, when the
issue was resolved we never circled back to fix the issue. Now trying to
enable python 3.8 support to terra cryptography >=2.8 is needed for
python 3.8 on windows (to get a precompiled binary). This commit removes
the unecessary pin to unblock windows 3.8 ci.

* Bump cibuildwheel version to build 3.8 wheels

cibuildwheel 1.0.0 was released in early November [1] and added support
for building python 3.8 wheels. This commit bumps the cibuildwheel
version we use in the wheel build jobs at release time to also build 3.8
wheels for upload to pypi.

* Add skip and release note about macos py38 issues

This commit adds a skip for the failing python 3.8 test on osx and
windows so that we don't block everything over a small issue in the
tests. It also add a release note documenting the limitation with python
3.8 on macos with regardess to parallel_map/multiprocessing. Since this
limitation is new for this release (being the first release with python
3.8 support) we should document it as a known issue in the release
notes, especially since it likely won't be resolved until a python 3.8.1
release.

* Revert "Add spawn guard for python3.8 osx in examples"

While we can fix the tests to work on osx python3.8 by adjusting the
example scripts to only call functions using parallel_map from inside a
block run via if __name__ == '__main__': this unecessarily changes the
scripts for the quirks of a single environment. This commit reverts the
example scripts back to their original form and instead just skips the
unittest that executes them on python 3.8 macOS. We already have
documented this limitation in the release notes. When/if we have an
alternative solution for how we launch additional processes in python
3.8 on macOS that does not require this workaround we can look at
removing the skip.

This reverts commit 76ae197631.

* Apply suggestions from code review

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>
2019-12-10 22:43:58 +02:00
Lauren Capelluto 1f9fb32bfe Deprecate cmd def (#3573)
* Add helpful methods to defaults. methods previously existed in cmddef. still TODO: replace_pulse and TESTS

Add tests and bonus backend.version() to match backend.name()

Implement replace_pulse. Add more tests. Fixup style.

Add back build_cmd_defaults with deprecation warning. Make qubit/meas_freq_est a list attribute again, and handle related dependencies in assemble.

The example json was incorrect: the acquire commands did not have all the values required to be valid

Ops order isn't meaningful, test same keys instead

Add type hints to file

Fix #2955: improved error messaging for CmdDef

Update __str__ method, fix style

Move replace pulse feature to different branch. Also move base backend work.

Add release notes

Fix bug in assembler due to inconsistent units

Change inputs to assembler tests

Fixup issues in frequency units in assemble and assemble tests. They are still in GHz

Suppress warnings during assemble

Use module name to resolve name conflict between qiskit.validation.fields.List and typing.List

Rename op_qubits to qubits_with_op. Move _to_tuple out of util. Remove unnecessary attributes.

Respond to CR by Naoki

remove deprecation warnings

Remove filterwarnings and fixup repr

* Separate InstructionScheduleMap, give it such a name, give it the ops_def attribute for access. repr->str.

* Fixup rebase error

* Fix tests, fix style

* Improve class initialization. Fix bug where qubit ops wasn't being updated

* Remove outdated raises documentation and unused import

* Remove warning on redefinition

* Fix up removing operations or qubits, raise error if qubits or op are not found, fill in str test

* Rename op/operation to inst/instruction

* Move map to pulse

* Update release note, final style fix

* Add deprecation warning to the CmdDef.

* Added InstructionScheduleMap tests.

* modify instruction schedule to no longer be mutable objects used by internal representation.

* Revert cmd_def changes.

* instruction scheduler map linting.

* Final tests fixup

* rename duplicate test name

* Remove copy, simplify qubit_insts

* rename qubit_insts to qubit_instructions

* rename qubits_with_inst to qubits_with_instruction

* Update qiskit/pulse/instruction_schedule_map.py

* Update qiskit/pulse/instruction_schedule_map.py

* Update releasenotes/notes/extend-backend-defaults-4370f983d599a26b.yaml

* Update releasenotes/notes/extend-backend-defaults-4370f983d599a26b.yaml

* linting.

* more linting.

* Add to_dict schema validation tests for assembler.

* Fixed bug where enums repr was being stored in to_dict.

* linting.

* Add helpful methods to defaults. methods previously existed in cmddef. still TODO: replace_pulse and TESTS

Add tests and bonus backend.version() to match backend.name()

Implement replace_pulse. Add more tests. Fixup style.

Add back build_cmd_defaults with deprecation warning. Make qubit/meas_freq_est a list attribute again, and handle related dependencies in assemble.

The example json was incorrect: the acquire commands did not have all the values required to be valid

Ops order isn't meaningful, test same keys instead

Add type hints to file

Fix #2955: improved error messaging for CmdDef

Update __str__ method, fix style

Move replace pulse feature to different branch. Also move base backend work.

Add release notes

Fix bug in assembler due to inconsistent units

Change inputs to assembler tests

Fixup issues in frequency units in assemble and assemble tests. They are still in GHz

Suppress warnings during assemble

Use module name to resolve name conflict between qiskit.validation.fields.List and typing.List

Rename op_qubits to qubits_with_op. Move _to_tuple out of util. Remove unnecessary attributes.

Respond to CR by Naoki

remove deprecation warnings

Remove filterwarnings and fixup repr

* Separate InstructionScheduleMap, give it such a name, give it the ops_def attribute for access. repr->str.

* Fixup rebase error

* Fix tests, fix style

* Improve class initialization. Fix bug where qubit ops wasn't being updated

* Remove outdated raises documentation and unused import

* Remove warning on redefinition

* Fix up removing operations or qubits, raise error if qubits or op are not found, fill in str test

* Rename op/operation to inst/instruction

* Move map to pulse

* Update release note, final style fix

* Add deprecation warning to the CmdDef.

* Added InstructionScheduleMap tests.

* modify instruction schedule to no longer be mutable objects used by internal representation.

* Revert cmd_def changes.

* instruction scheduler map linting.

* Final tests fixup

* rename duplicate test name

* Remove copy, simplify qubit_insts

* rename qubit_insts to qubit_instructions

* rename qubits_with_inst to qubits_with_instruction

* Update qiskit/pulse/instruction_schedule_map.py

* Update qiskit/pulse/instruction_schedule_map.py

* Update releasenotes/notes/extend-backend-defaults-4370f983d599a26b.yaml

* Update releasenotes/notes/extend-backend-defaults-4370f983d599a26b.yaml

* linting.

* more linting.

* Switched cmd_def scheduluer tests to instruction_map and added cmd_def tests to eventually deprecated.

* Renamed InstructionScheduleMap to be InstructionScheduleMapping to be more pythonic and grammatically correct.

* name InstructionScheduleMapping to InstructionScheduleMap and defaults.instruction_schedulues to defaults.circuit_instruction_map

* fix scheduluer test.

* linting fix.

* Deprecate CmdDef in favor of PulseDefaults and migrate tests elsewhere to use defaults

* Update renamed attribute

In recent revisions to PulseDefaults the instruction_schedules attribute
has been renamed circuit_instruction_map. This commit updates outdated
references to the old revision.

* Update deprecation warning too

* Add release note
2019-12-09 21:05:40 -05:00
Lauren Capelluto 007d47852f Format pulse defaults (#3526)
Fixes:

Fixes #2955 (improved error message for CmdDef.get)
Fixes #2861 (improved repr and str for CmdDef)

Changes:

qubit_freq_est and meas_freq_est now return frequency in Hz. (no warnings)
Replacing CmdDef

CmdDef will be deprecated following this PR. All existing methods are supported by
InstructionScheduleMap (via defaults().ops_def rather than .from_defaults()) with the
following exceptions:

-  __init__ should be blank unless provided by the PulseDefaults object being initialized
- add should be used instead of init args by the user
- cmds and cmd_qubits are included with a deprecation message to use ops and
  qubits_with_op instead.

New (not in CmdDef):

- qubit_ops(qubits): Return the operations that are defined for the qubit(s)
- assert_has(operation, qubits): Raise a PulseError if the op isn't defined
- remove(operation, qubits)

* Add helpful methods to defaults. methods previously existed in cmddef. still TODO: replace_pulse and TESTS

Add tests and bonus backend.version() to match backend.name()

Implement replace_pulse. Add more tests. Fixup style.

Add back build_cmd_defaults with deprecation warning. Make qubit/meas_freq_est a list attribute again, and handle related dependencies in assemble.

The example json was incorrect: the acquire commands did not have all the values required to be valid

Ops order isn't meaningful, test same keys instead

Add type hints to file

Fix #2955: improved error messaging for CmdDef

Update __str__ method, fix style

Move replace pulse feature to different branch. Also move base backend work.

Add release notes

Fix bug in assembler due to inconsistent units

Change inputs to assembler tests

Fixup issues in frequency units in assemble and assemble tests. They are still in GHz

Suppress warnings during assemble

Use module name to resolve name conflict between qiskit.validation.fields.List and typing.List

Rename op_qubits to qubits_with_op. Move _to_tuple out of util. Remove unnecessary attributes.

Respond to CR by Naoki

remove deprecation warnings

Remove filterwarnings and fixup repr

* Separate InstructionScheduleMap, give it such a name, give it the ops_def attribute for access. repr->str.

* Fixup rebase error

* Fix tests, fix style

* Improve class initialization. Fix bug where qubit ops wasn't being updated

* Remove outdated raises documentation and unused import

* Remove warning on redefinition

* Fix up removing operations or qubits, raise error if qubits or op are not found, fill in str test

* Rename op/operation to inst/instruction

* Move map to pulse

* Update release note, final style fix

* Add deprecation warning to the CmdDef.

* Added InstructionScheduleMap tests.

* modify instruction schedule to no longer be mutable objects used by internal representation.

* Revert cmd_def changes.

* instruction scheduler map linting.

* Final tests fixup

* rename duplicate test name

* Remove copy, simplify qubit_insts

* rename qubit_insts to qubit_instructions

* rename qubits_with_inst to qubits_with_instruction

* Update qiskit/pulse/instruction_schedule_map.py

* Update qiskit/pulse/instruction_schedule_map.py

* Update releasenotes/notes/extend-backend-defaults-4370f983d599a26b.yaml

* Update releasenotes/notes/extend-backend-defaults-4370f983d599a26b.yaml

* linting.

* more linting.

* Add to_dict schema validation tests for assembler.

* Fixed bug where enums repr was being stored in to_dict.

* linting.

* Add helpful methods to defaults. methods previously existed in cmddef. still TODO: replace_pulse and TESTS

Add tests and bonus backend.version() to match backend.name()

Implement replace_pulse. Add more tests. Fixup style.

Add back build_cmd_defaults with deprecation warning. Make qubit/meas_freq_est a list attribute again, and handle related dependencies in assemble.

The example json was incorrect: the acquire commands did not have all the values required to be valid

Ops order isn't meaningful, test same keys instead

Add type hints to file

Fix #2955: improved error messaging for CmdDef

Update __str__ method, fix style

Move replace pulse feature to different branch. Also move base backend work.

Add release notes

Fix bug in assembler due to inconsistent units

Change inputs to assembler tests

Fixup issues in frequency units in assemble and assemble tests. They are still in GHz

Suppress warnings during assemble

Use module name to resolve name conflict between qiskit.validation.fields.List and typing.List

Rename op_qubits to qubits_with_op. Move _to_tuple out of util. Remove unnecessary attributes.

Respond to CR by Naoki

remove deprecation warnings

Remove filterwarnings and fixup repr

* Separate InstructionScheduleMap, give it such a name, give it the ops_def attribute for access. repr->str.

* Fixup rebase error

* Fix tests, fix style

* Improve class initialization. Fix bug where qubit ops wasn't being updated

* Remove outdated raises documentation and unused import

* Remove warning on redefinition

* Fix up removing operations or qubits, raise error if qubits or op are not found, fill in str test

* Rename op/operation to inst/instruction

* Move map to pulse

* Update release note, final style fix

* Add deprecation warning to the CmdDef.

* Added InstructionScheduleMap tests.

* modify instruction schedule to no longer be mutable objects used by internal representation.

* Revert cmd_def changes.

* instruction scheduler map linting.

* Final tests fixup

* rename duplicate test name

* Remove copy, simplify qubit_insts

* rename qubit_insts to qubit_instructions

* rename qubits_with_inst to qubits_with_instruction

* Update qiskit/pulse/instruction_schedule_map.py

* Update qiskit/pulse/instruction_schedule_map.py

* Update releasenotes/notes/extend-backend-defaults-4370f983d599a26b.yaml

* Update releasenotes/notes/extend-backend-defaults-4370f983d599a26b.yaml

* linting.

* more linting.

* Switched cmd_def scheduluer tests to instruction_map and added cmd_def tests to eventually deprecated.

* Renamed InstructionScheduleMap to be InstructionScheduleMapping to be more pythonic and grammatically correct.

* name InstructionScheduleMapping to InstructionScheduleMap and defaults.instruction_schedulues to defaults.circuit_instruction_map

* fix scheduluer test.

* linting fix.
2019-12-09 20:02:22 -05:00
Thomas Alexander 5ef1751388 Fix enum meas_return to_dict bug (#3582)
* Add to_dict schema validation tests for assembler.

* Fixed bug where enums repr was being stored in to_dict.

* linting.
2019-12-09 22:06:32 +00:00
ewinston db8851313b Fix phase for controlled Rz (#3569)
* fix crz

* add implementation for controlled unitary

* fix crz

* add implementation for controlled unitary

* remove phase arg from controlled unitary

* linting
2019-12-09 16:34:31 -05:00
Christopher J. Wood 72b72dfbd9 Fix transpile to only check for max qubits if backend is not a simulator (#3578)
* Fix transpile to only check for max qubits if not a simulator

* add tests

* fixup

* linting
2019-12-09 14:22:30 -05:00
AzizNgoueya 6f565d4741 Add argument to ignore framechange only channels for schedules drawing (#3441)
* use update method of set() for readability

* Add unittest test_schedule_matplotlib_drawer_show_framechange

* Style and Lint

* Style and Lint
2019-12-09 11:16:54 +00:00
Kevin Krsulich 256552c131 Decompose substitute_node only when gate width matches definition. (#3566) 2019-12-09 09:05:19 +00:00
Lauren Capelluto 3c22026511 Fix Scheduler MemorySlot mapping (issue #2704) (#3567)
* fix MeasureChannel

* fix bug

* fix bug in bug

* Fix MemorySlots

* tweaking

* Fix typo

* Update the condition

This commit intends to change the idea of raising Pulse error when the length of mem_slots and acquires are not equal. The main idea of this PR is to output the user only those channels and memory slots that the user used.

* Revert "Update the condition"

This reverts commit 0b14dbd4b7.

* Cleaning up

* Fix typo

* tweaking m_slots

* Refactoring the logic

* Remove ipdb

* Added tests

* Fixed review suggestions

* Add docstring to test

* release notes

* typo

* Fix review suggestions

* fix release notes

* Adding more tests

* Fix Lint

* fix typo in test

* remove ipdb

* test test

* tweaking test

* lint

* fix review suggestions

* Remove assert (PR #225)

* avoid shift and or

* Remove or and shift operator from test

* Tests

* Add Github issue reference to release notes

* Update release notes

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

* Added descriptive QiskitError message

* Add GitHub Issue link to release notes

* Remove release note

Release note is not required because Scheduler has not been included in any previous releases

* Update tests

* assertEqual instructions
2019-12-08 17:37:57 +00:00
Kevin Krsulich 255c297403 MergeAdjacentBarriers to first check if barriers are adjacent. (#3481)
* MergeAdjacentBarriers to first check if barriers are adjacent.

* Remove test allowing merger of disjoint barriers.
2019-12-06 22:03:45 +00:00
Paul Nation fd33db9e48 Use backend n_qubits to check if circuit can fit on device if coupling_map is None (#3557)
* fix 1Q transpilation

* fix for backend=None

* Delete TESTING.ipynb

* testing 1Q

* A more generic condition

* release notes

* lint

* https://github.com/Qiskit/qiskit-terra/pull/3557/#discussion_r354864664

* https://github.com/Qiskit/qiskit-terra/pull/3557/#discussion_r354864791

* https://github.com/Qiskit/qiskit-terra/pull/3557/#discussion_r354867778
2019-12-06 20:54:35 +00:00
dime10 e81f5511a7 Improve inverse function for ControlledGate class (#3534)
* Adding inverse function to the ControlledGate class that calls the inverse of the base gate instead of relying on the one defined in Instruction. Includes test function.

* linting

* Fixed inverse when gate is directly of Type 'Gate', e.g. from a circuit to gate call.

* remove reference to ubase

ubase was recently removed.
2019-12-06 15:13:41 -05:00
Matthew Treinish d84f507569
Handle cregs in circuit_to_gate() converter (#3555)
* Handle cregs in circuit_to_gate() converter

Prior to this commit the circuit_to_get converter function was not
handling cregs at all. This led to an output definition with
instruction tuples of length 2 (inst object, [qbits]) instead of length
3 (inst object, [qbits], [cbits]). This would then cause potential
issues for operations that were assuming the standardized data format
with length three. This includes the inverse() method of a gate. This
commit fixes this issue by adding creg handling to the output gate
definition generation. While the only instructions with cregs set don't
have to_gate() methods and the converter won't work with them this is
still necessary to maintain compatibility with all gate methods, it will
just mean that cregs will always end up with [] except in the case of
custom gate defintions. The logic was also reworked to be slightly easier
to read since having multiple layers of nested map() calls gets hard to
debug.

Fixes #3545

* Just hardcode output cregs to empty list

Since gate objects can't have cregs set instead of going through all the
effort of trying to map what will always be an empty list this commit
just pivots this to hardcode the output clbit list to be an empty list.
This simplifies the code, and a commented is added to explain why.

* Add a test
2019-12-06 07:03:13 -05:00
Kevin Krsulich 4d36c9fb97 Revert "Run BarrierBeforeFinalMeasurements pass regardless of property_set['is_swap_mapped'] (#3273)" (#3558)
This reverts commit b0395c1d36.
2019-12-05 22:24:35 +00:00
Cameron McGarry f273f6eb93 Fix side effects of setting numpy.random.seed (#3541)
* Test for global scoping of numpy seed in random_unitary

* Test for global scoping of numpy seed in random_density_matrix

* Fix numpy seed effects in random_unitary

* Fix numpy seed effects in __ginibre_matrix

* Fix numpy seed effects in pauli operators

* Release notes, patch issue #2850

* Linting

* Update releasenotes/notes/fix-numpy.random.seed-after-effects-74630974e79b1b7f.yaml

Co-Authored-By: SooluThomas <soolu.elto@gmail.com>

* Update releasenotes/notes/fix-numpy.random.seed-after-effects-74630974e79b1b7f.yaml

Co-Authored-By: SooluThomas <soolu.elto@gmail.com>
2019-12-05 21:30:52 +00:00
Luciano Bello 1e0d3ae18a Round of deprecation removal (#3190)
* BaseModel.as_dict

* _parse_basis_gates

* Layout support for tuples

* bit.__getitem__

* layout from_tuplelist

* eq for bit

* tuple as gate arguments

* import warnings

* test/python/test_dagcircuit.py

* test.python.test_dagcircuit.TestDagRegisters.test_dag_get_qubits

* rest of test.python.test_dagcircuit

* fixing test.python.circuit.test_circuit_registers

* test.python.circuit.test_circuit_data.TestQuantumCircuitInstructionData.test_setting_data_is_validated

* test.python.circuit.test_circuit_data

* lint

* release note

* release notes
2019-12-03 18:03:43 +00:00
ewinston c4809d438c added release notes for controlled gate class (#2862). (#3465)
* added release notes for controlled gate class (#2862).

Also remove some unused imports in test_controlled_gate.py.

* remove pylint disable

* remove one more unused import

* change q_if to control 

in expectation of pr #3455

* update release notes

include imports in release notes.
2019-11-30 13:38:57 +00:00
Paul Nation 13f75e2324 Add ability to get counts from statevectors and density matrices (#3514)
* add state to counts

* add to result and tests

* style

* cleanup

* add DM version and tests

* lint
2019-11-27 04:02:58 +00:00
ewinston e6096b24d7 add test for to_matrix method of standard gates (#3469)
* start to_matrix method for ControlledGate

* add test to check to_matrix of standard gates

* remove stale code

* remove to_matrix from ControlledGate

consider adding back later.

* linting

* add exceptions to catch

* linting

* remove unused import
2019-11-27 03:28:48 +00:00
Paul Nation 7025b1c494 Add Hellinger fidelity discrete probability measure. (#3510)
* add hellinger fidelity

* style

* add test and clean up example

* example missing circuit
2019-11-25 16:48:21 +00:00
Paul Nation 103f6ffcee fix no reg depth (#3513) 2019-11-24 11:41:16 +00:00
Kevin Krsulich bd19bb1e16 Add FakeRochester to mock backends. (#3504) 2019-11-22 03:22:52 +00:00
Ali Javadi-Abhari c3cdd355d3
Result marginal counts (#3446)
* add Result.get_marginal_counts

* add Result.get_marginal_counts

* releasenote

* move to result utility funcs

* add file

* lint

* lint

* ability to marginalize a Result object

* style

* avoid cyclic import
2019-11-21 13:17:01 -05:00
Daniel Puzzuoli 3bbdf32289 Issue #3496: empty filter bug for pulse.Schedule (#3498)
* added check for empty filters in Schedule._construct_filter

* added tests for empty filters for Schedule.filter and Schedule.exclude

* fixed style issue in test_schedule for filter testing

* simplified if statements in Schedule._construct_filter
2019-11-20 20:28:17 +00:00
Iskandar Sitdikov 3a7763b10e Pulse: improved error message for overlapping pulses; Fixes #2523 (#3319)
* Pulse: improved error message for overlapping pulses; Fixes #2523

* Style: lint check fixes

* Interval: optional get overlap

* Pulse: timeslots error fix, schedule repr fix, schedules overlap test

* Schedule: format message + fix tests

* Schedule: context fixes
2019-11-20 19:43:45 +00:00
Tharrmashastha SAPV fa9ab527f4 Gate parameters support mix of indexes and bits (#3490)
* Fixed issue #2369 by updating quantumcircuit.py

* added test

* Update test_circuit_registers.py

* Update test_circuit_registers.py
2019-11-20 17:07:09 +00:00
Luciano a859f85e56 Removing U0Gate (#3431)
* remove u0

* release note

* test_unroller.py

* test_text_drawer

* refs

* test/randomized/test_transpiler_equivalence.py

* 0.8 -> 0.9
2019-11-20 08:07:55 +00:00
Ali Javadi-Abhari 12bbc237b6 replace q_if with control (#3455)
* replace q_if with control

* fix test

* instruction_to_gate -> circuit_to_gate

* lint

* fix tests

* lint

* remove control from instructionset as not implemented
2019-11-20 06:16:36 +00:00
Luciano 5b89b4c1cb syncing qiskit/qasm/libs/qelib1.inc and qiskit/extensions/standard/cu3.py (#3479)
* update qiskit/qasm/libs/qelib1.inc according to #2755

* re adjust the length

* test
2019-11-20 02:41:33 +00:00
Luciano 7f1b549856 unused-import (#3487) 2019-11-19 10:17:26 -05:00
Ali Javadi-Abhari 89cb7afc68
fix pulse draw failures on channels_to_plot (#3483)
* fix pulse draw failures on channels_to_plot

* update test

* still skip tests
2019-11-16 08:39:25 -06:00
Lauren Capelluto 4345c57fe2 Bugfix/issue 3387 adding late gates (#3411)
* Fix bug

* Add test

* Remove trailing whitespace

* Fix scheduling issue: barriers were being treated differently, and shouldn't have been
2019-11-15 19:02:45 +00:00
Matt-Stypulkoski b0395c1d36 Run BarrierBeforeFinalMeasurements pass regardless of property_set['is_swap_mapped'] (#3273)
* Run BarrierBeforeFinalMeasurements pass regardless of property_set['is_swap_mapped']

* Fix test_after_transpile expected circuit drawing to include barriers before measurements

* Make test_after_transpile expected output a class attribute to fit within the line-length lint and style check
2019-11-14 16:48:34 +00:00
Luciano c1805f5607 TestTextWithLayout is using line_length, which is deprecated (#3430) 2019-11-13 15:28:57 +00:00
Luciano 05959124a4 Params in controlled gates (#3454)
* params in controlled gates

* Update text.py

* Update text.py
2019-11-12 16:18:58 -05:00
Luciano f023fa32c0 CSP layout selector (#3043)
* some utf8 art

* CSP layout

* add dependency and test

* bug in undirected cm

* release notes and changelog

* rest

* docstring

* optional req

* lint

* disable

* import

* lint
2019-11-12 20:40:30 +00:00
Ali Javadi-Abhari 6eab4d7620
fix no ibmq.backends() (#3456) 2019-11-12 14:40:54 -05:00
Luciano 576f804e1c controlled gate text drawer (#3442)
* added ControlledGate class

updated standard gates to return controlled version if it is also in the standard set.

* added assertions to some tests.

minor commit

added "controlled_ops" parameter

gate rules of gate before applying controls.

pass controlled gate tests

changing to recursive control

broken point

* added dmitri based decomposition from aqua

passing mu1 and mu3

tests working...confusing num_ctrl_qubits

linting

fix indentation error

fix circular import for python 3.5 and 3.6.

more import fixes

put aqua q_if back in, linting

minor commit

minor commit

linting

another attempt to fix circular import across all pltforms.

disable cyclic-import pylint check

another attempt to remove cyclic import

This also eliminates defining q_if in standard extension gates.

forgot to add module add_control.py

fix style

method from qi

* copied multi controlled gates from aqua

todo: convert the gates to ControlledGates

linting

style

simplify some tests

minor fix

* simplify code. catch rotation gates to avoid decomposition.

* copied multi controlled gates from aqua

todo: convert the gates to ControlledGates

linting

style

simplify some tests

minor fix

Co-authored-by: Shaohan Hu <shaohan.hu@ibm.com>
Co-authored-by: Manoel Marques <manoel@us.ibm.com>
Co-authored-by: Albert Frisch <alfr@de.ibm.com>

* simplify code. catch rotation gates to avoid decomposition.

* add reference to base controlled gate

This adds "base_gate" as class attribute of ControlledGate which is a class reference.

* add some tests. fix imports

* remove pdb

* linting

* add `to_gate` method to Instruction.

* lint

* linting

* linting

* add test for instruction_to_gate

* add phase argument when computing control matrix

* linting

* inital commit

* more testing!

* wrong-import-order

* label
2019-11-12 16:18:11 +00:00
ewinston 370b27e56a add ControlledGate class (#2862)
* added ControlledGate class

updated standard gates to return controlled version if it is also in the standard set.

* added assertions to some tests.

minor commit

added "controlled_ops" parameter

gate rules of gate before applying controls.

pass controlled gate tests

changing to recursive control

broken point

* added dmitri based decomposition from aqua

passing mu1 and mu3

tests working...confusing num_ctrl_qubits

linting

fix indentation error

fix circular import for python 3.5 and 3.6.

more import fixes

put aqua q_if back in, linting

minor commit

minor commit

linting

another attempt to fix circular import across all pltforms.

disable cyclic-import pylint check

another attempt to remove cyclic import

This also eliminates defining q_if in standard extension gates.

forgot to add module add_control.py

fix style

method from qi

* copied multi controlled gates from aqua

todo: convert the gates to ControlledGates

linting

style

simplify some tests

minor fix

* simplify code. catch rotation gates to avoid decomposition.

* copied multi controlled gates from aqua

todo: convert the gates to ControlledGates

linting

style

simplify some tests

minor fix

Co-authored-by: Shaohan Hu <shaohan.hu@ibm.com>
Co-authored-by: Manoel Marques <manoel@us.ibm.com>
Co-authored-by: Albert Frisch <alfr@de.ibm.com>

* simplify code. catch rotation gates to avoid decomposition.

* add reference to base controlled gate

This adds "base_gate" as class attribute of ControlledGate which is a class reference.

* add some tests. fix imports

* remove pdb

* linting

* add `to_gate` method to Instruction.

* lint

* linting

* linting

* add test for instruction_to_gate

* add phase argument when computing control matrix

* linting
2019-11-12 05:12:31 +00:00
Lauren Capelluto 4c5354c04a Deprecate backend config replacement (#3367)
* Deprate PulseChannelSpec, deprecate Qubit, remove system topology (which was a helper for pulsechannelspec) and migrate tests to use backend.configuration instead

* Continue testt migration from more recent code

Add release notes about PulseChannelSpec deprecation.

Update AcquireInstruction to no longer support Qubit input type (rarely used).

* Fixup bug in test schedule
2019-11-11 21:07:39 +00:00
Lauren Capelluto b961430cc5 Remove warning about units of dt (#3448)
* Remove warning about units of dt

* Remove unused import warnings

* Fixup issue with dt and dtm being set, include warnings for control method
2019-11-11 18:22:06 +00:00
Matthew Treinish 37036f494d Rewrite dag drawer to not use nxpd (#3280)
* 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
2019-11-09 04:49:46 +00:00
Luciano 6bfadcd253 a less noisy test_deprecated (#3439)
* test_basicaer_backends logger

* cm->context
2019-11-09 03:56:04 +00:00
Christopher J. Wood cf9c3f8d11 Fixes bug in concurrence using ``eigh`` instead of ``eigvals`` for possibly non-hermitian matrices (#3376)
* fix qi.concurrence

* Fix tests for concurrence and entanglement of formation

* unused import
2019-11-06 20:56:54 +00:00
Paul Nation 9134634f43 Module-level docstrings for Terra (#3325)
* add tools.jupyter docs

* execute device visualizations

* add examples to QuantumCircuit and execute

* lint

* update execute docs

* add basicaer docs

* Add workaround for running with IBMQ examples everywhere

* updates

* lint

* Add graphviz to docs job

* add extensions module-level docstirngs

* more module level docs

* updates

* more updates

* transpiler docs and lint

* all but tools

* jupyter tools

* fix import issue

* tools module

* remove automod

* new line

* fix test using function with wrong name

* updates
2019-11-06 18:46:45 +00:00
Ali Javadi-Abhari 2ba8f299df fix zeroed_width issues, make default sampling midpoint (#3314)
* fix zeroed_width for gaussian and gaussian_square

* fix some definitions

* fix test

* make sampler midpoint by default

* fix rescale_amp docstrings, fix tests to reflect midpoint, fix sech
2019-11-06 13:14:09 -05:00