Skip to content

Commit

Permalink
rebase ion-trap branch (#3153)
Browse files Browse the repository at this point in the history
* 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 effad12.

* 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)
  • Loading branch information
ajavadia authored and kdk committed Sep 26, 2019
1 parent 80a22a6 commit ef06abe
Show file tree
Hide file tree
Showing 26 changed files with 596 additions and 1,512 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ notifications:
email: false

cache: pip
sudo: false

###############################################################################
# Anchored and aliased definitions.
Expand Down
1,326 changes: 0 additions & 1,326 deletions CHANGELOG.md

This file was deleted.

50 changes: 42 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,31 @@ please ensure that:
3. If it makes sense for your change that you have added new tests that
cover the changes.
4. Ensure that if your change has an end user facing impact (new feature,
deprecation, removal etc) that you have updated the CHANGELOG.md and
added a reno release note for that change.
deprecation, removal etc) that you have added a reno release note for that
change and that the PR is tagged for the changelog.

### Changelog generation

The changelog is automatically generated as part of the release process
automation. This works through a combination of the git log and the pull
request. When a release is tagged and pushed to github the release automation
bot looks at all commit messages from the git log for the release. It takes the
PR numbers from the git log (assuming a squash merge) and checks if that PR had
a `Changelog:` label on it. If there is a label it will add the git commit
message summary line from the git log for the release to the changelog.

If there are multiple `Changelog:` tags on a PR the git commit message summary
line from the git log will be used for each changelog category tagged.

The current categories for each label are as follows:

| PR Label | Changelog Category |
| -----------------------|--------------------|
| Changelog: Deprecation | Deprecated |
| Changelog: New Feature | Added |
| Changelog: API Change | Changed |
| Changelog: Removal | Removed |
| Changelog: Bugfix | Fixed |

### Commit messages

Expand Down Expand Up @@ -157,6 +180,10 @@ git annotate messages, gitk viewer annotations, merge commit messages, and many
more places where space is at a premium. As well as summarizing the change
itself, it should take care to detail what part of the code is affected.

In addition the first line of the commit message gets used as entries in the
generated changelog if the PR is tagged as being included in the changelog.
It's critically important that you write a clear and succinct summary lines.

* Describe any limitations of the current code.

If the code being changed still has future scope for improvements, or any known
Expand Down Expand Up @@ -450,7 +477,7 @@ the project boards in Github for project management. We use milestones
in Github to track work for specific releases. The features or other changes
that we want to include in a release will be tagged and discussed in Github.
As we're preparing a new release we'll document what has changed since the
previous version in the release notes and Changelog.
previous version in the release notes.

### Branches

Expand All @@ -471,11 +498,18 @@ merged to it are bugfixes.

When it is time to release a new minor version of qiskit-terra we will:

1. Create a stable branch for the new minor version from the current
HEAD on the `master` branch
2. Create a new tag with the version number on the HEAD of the new stable
branch.
3. Change the `master` version to the next release version.
1. Create a new tag with the version number and push it to github
2. Change the `master` version to the next release version.

The release automation processes will be triggered by the new tag and perform
the following steps:

1. Create a stable branch for the new minor version from the release tag
on the `master` branch
2. Build and upload binary wheels to pypi
3. Create a github release page with a generated changelog
4. Generate a PR on the meta-repository to bump the terra version and
meta-package version.

The `stable/*` branches should only receive changes in the form of bug
fixes.
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,27 @@ Now you're set up and ready to check out some of the other examples from our
Qiskit Terra is the work of [many people](https://github.com/Qiskit/qiskit-terra/graphs/contributors) who contribute
to the project at different levels. If you use Qiskit, please cite as per the included [BibTeX file](https://github.com/Qiskit/qiskit/blob/master/Qiskit.bib).

## Changelog and Release Notes

The changelog for a particular release is dynamically generated and gets
written to the release page on Github for each release. For example, you can
find the page for the `0.9.0` release here:

https://github.com/Qiskit/qiskit-terra/releases/tag/0.9.0

The changelog for the current release can be found in the releases tab:
![](https://img.shields.io/github/release/Qiskit/qiskit-terra.svg?style=popout-square)
The changelog provides a quick overview of noteable changes for a given
release.

Additionally, as part of each release detailed release notes are written to
document in detail what has changed as part of a release. This includes any
documentation on potential breaking changes on upgrade and new features.
For example, You can find the release notes for the `0.9.0` release in the
Qiskit documentation here:

https://qiskit.org/documentation/release_notes.html#terra-0-9

## License

[Apache License 2.0](LICENSE.txt)
2 changes: 1 addition & 1 deletion qiskit/assembler/assemble_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def assemble_schedules(schedules, qobj_id, qobj_header, run_config):
instruction = PulseInstruction(
command=SamplePulse(name=name, samples=instruction.command.samples),
name=instruction.name,
channel=instruction.timeslots.channels[0])
channel=instruction.channels[0])
# add samples to pulse library
user_pulselib[name] = instruction.command

Expand Down
6 changes: 3 additions & 3 deletions qiskit/circuit/quantumcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def mirror(self):
reverse_circ = self.copy(name=self.name + '_mirror')
reverse_circ._data = []
for inst, qargs, cargs in reversed(self.data):
reverse_circ.append((inst.mirror(), qargs, cargs))
reverse_circ.append(inst.mirror(), qargs, cargs)
return reverse_circ

def inverse(self):
Expand Down Expand Up @@ -234,7 +234,7 @@ def combine(self, rhs):
combined_cregs.append(element)
circuit = QuantumCircuit(*combined_qregs, *combined_cregs)
for instruction_context in itertools.chain(self.data, rhs.data):
circuit.append(*instruction_context)
circuit._append(*instruction_context)
return circuit

def extend(self, rhs):
Expand All @@ -261,7 +261,7 @@ def extend(self, rhs):

# Add new gates
for instruction_context in rhs.data:
self.append(*instruction_context)
self._append(*instruction_context)
return self

@property
Expand Down
9 changes: 7 additions & 2 deletions qiskit/compiler/transpile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from qiskit.circuit.quantumregister import Qubit
from qiskit import user_config
from qiskit.transpiler.exceptions import TranspilerError
from qiskit.converters import isinstanceint, isinstancelist


def transpile(circuits,
Expand Down Expand Up @@ -330,13 +331,17 @@ def _parse_initial_layout(initial_layout, circuits):
# initial_layout could be None, or a list of ints, e.g. [0, 5, 14]
# or a list of tuples/None e.g. [qr[0], None, qr[1]] or a dict e.g. {qr[0]: 0}
def _layout_from_raw(initial_layout, circuit):
if isinstance(initial_layout, list):
if all(isinstance(elem, int) for elem in initial_layout):
if initial_layout is None or isinstance(initial_layout, Layout):
return initial_layout
elif isinstancelist(initial_layout):
if all(isinstanceint(elem) for elem in initial_layout):
initial_layout = Layout.from_intlist(initial_layout, *circuit.qregs)
elif all(elem is None or isinstance(elem, Qubit) for elem in initial_layout):
initial_layout = Layout.from_qubit_list(initial_layout)
elif isinstance(initial_layout, dict):
initial_layout = Layout(initial_layout)
else:
raise TranspilerError("The initial_layout parameter could not be parsed")
return initial_layout

# multiple layouts?
Expand Down
22 changes: 22 additions & 0 deletions qiskit/converters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,25 @@
from .dag_to_circuit import dag_to_circuit
from .ast_to_dag import ast_to_dag
from .circuit_to_instruction import circuit_to_instruction


def isinstanceint(obj):
""" Like isinstance(obj,int), but with casting. Except for strings."""
if isinstance(obj, str):
return False
try:
int(obj)
return True
except TypeError:
return False


def isinstancelist(obj):
""" Like isinstance(obj, list), but with casting. Except for strings and dicts."""
if isinstance(obj, (str, dict)):
return False
try:
list(obj)
return True
except TypeError:
return False
1 change: 0 additions & 1 deletion qiskit/pulse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@
from .configuration import LoConfig, LoRange
from .exceptions import PulseError
from .interfaces import ScheduleComponent
# from .parser import parse_string_expr
from .schedule import Schedule
8 changes: 5 additions & 3 deletions qiskit/pulse/commands/sample_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def samples(self):
"""Return sample values."""
return self._samples

def _clip(self, samples: np.ndarray, epsilon: float = 1e-6):
def _clip(self, samples: np.ndarray, epsilon: float = 1e-5):
"""If samples are within epsilon of unit norm, clip sample by reducing norm by (1-epsilon).
If difference is greater than epsilon error is raised.
Expand Down Expand Up @@ -86,8 +86,10 @@ def _clip(self, samples: np.ndarray, epsilon: float = 1e-6):

return samples

def draw(self, dt: float = 1, style: Optional['PulseStyle'] = None,
filename: Optional[str] = None, interp_method: Optional[Callable] = None,
def draw(self, dt: float = 1,
style: Optional['PulseStyle'] = None,
filename: Optional[str] = None,
interp_method: Optional[Callable] = None,
scaling: float = 1, interactive: bool = False):
"""Plot the interpolated envelope of pulse.
Expand Down
1 change: 0 additions & 1 deletion qiskit/tools/jupyter/backend_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,5 +562,4 @@ def get_date(job):
ax.add_artist(Circle((0, 0), 0.7, color='white', zorder=1))
ax.text(0, 0, total_jobs, horizontalalignment='center',
verticalalignment='center', fontsize=26)
fig.tight_layout()
return fig
11 changes: 6 additions & 5 deletions qiskit/transpiler/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from qiskit.circuit.quantumregister import Qubit
from qiskit.transpiler.exceptions import LayoutError
from qiskit.converters import isinstanceint


class Layout():
Expand Down Expand Up @@ -87,11 +88,11 @@ def from_dict(self, input_dict):
@staticmethod
def order_based_on_type(value1, value2):
"""decides which one is physical/virtual based on the type. Returns (virtual, physical)"""
if isinstance(value1, int) and isinstance(value2, (Qubit, type(None))):
physical = value1
if isinstanceint(value1) and isinstance(value2, (Qubit, type(None))):
physical = int(value1)
virtual = value2
elif isinstance(value2, int) and isinstance(value1, (Qubit, type(None))):
physical = value2
elif isinstanceint(value2) and isinstance(value1, (Qubit, type(None))):
physical = int(value2)
virtual = value1
else:
raise LayoutError('The map (%s -> %s) has to be a (Bit -> integer)'
Expand Down Expand Up @@ -272,7 +273,7 @@ def from_intlist(int_list, *qregs):
Raises:
LayoutError: Invalid input layout.
"""
if not all(isinstance(i, int) for i in int_list):
if not all(isinstanceint(i) for i in int_list):
raise LayoutError('Expected a list of ints')
if len(int_list) != len(set(int_list)):
raise LayoutError('Duplicate values not permitted; Layout is bijective.')
Expand Down
9 changes: 4 additions & 5 deletions qiskit/visualization/circuit_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def circuit_drawer(circuit,
return _text_circuit_drawer(circuit, filename=filename,
line_length=line_length,
reverse_bits=reverse_bits,
plotbarriers=plot_barriers,
plot_barriers=plot_barriers,
justify=justify,
vertical_compression=vertical_compression,
idle_wires=idle_wires,
Expand Down Expand Up @@ -327,7 +327,6 @@ def qx_color_scheme():
"latexdrawerstyle": True,
"usepiformat": False,
"cregbundle": False,
"plotbarrier": False,
"showindex": False,
"compress": True,
"margin": [2.0, 0.0, 0.0, 0.3],
Expand All @@ -342,7 +341,7 @@ def qx_color_scheme():


def _text_circuit_drawer(circuit, filename=None, line_length=None, reverse_bits=False,
plotbarriers=True, justify=None, vertical_compression='high',
plot_barriers=True, justify=None, vertical_compression='high',
idle_wires=True, with_layout=True):
"""
Draws a circuit using ascii art.
Expand All @@ -355,7 +354,7 @@ def _text_circuit_drawer(circuit, filename=None, line_length=None, reverse_bits=
shutil.get_terminal_size(). If you don't want pagination
at all, set line_length=-1.
reverse_bits (bool): Rearrange the bits in reverse order.
plotbarriers (bool): Draws the barriers when they are there.
plot_barriers (bool): Draws the barriers when they are there.
justify (str) : `left`, `right` or `none`. Defaults to `left`. Says how
the circuit should be justified.
vertical_compression (string): `high`, `medium`, or `low`. It merges the
Expand All @@ -375,7 +374,7 @@ def _text_circuit_drawer(circuit, filename=None, line_length=None, reverse_bits=
else:
layout = None
text_drawing = _text.TextDrawing(qregs, cregs, ops, layout=layout)
text_drawing.plotbarriers = plotbarriers
text_drawing.plotbarriers = plot_barriers
text_drawing.line_length = line_length
text_drawing.vertical_compression = vertical_compression

Expand Down
16 changes: 15 additions & 1 deletion qiskit/visualization/gate_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,21 @@ def plot_gate_map(backend, figsize=None,

mpl_data[5] = [[1, 0], [0, 1], [1, 1], [1, 2], [2, 1]]

mpl_data[53] = [[0, 2], [0, 3], [0, 4], [0, 5], [0, 6],
[1, 2], [1, 6],
[2, 0], [2, 1], [2, 2], [2, 3], [2, 4],
[2, 5], [2, 6], [2, 7], [2, 8],
[3, 0], [3, 4], [3, 8],
[4, 0], [4, 1], [4, 2], [4, 3], [4, 4],
[4, 5], [4, 6], [4, 7], [4, 8],
[5, 2], [5, 6],
[6, 0], [6, 1], [6, 2], [6, 3], [6, 4],
[6, 5], [6, 6], [6, 7], [6, 8],
[7, 0], [7, 4], [7, 8],
[8, 0], [8, 1], [8, 2], [8, 3], [8, 4],
[8, 5], [8, 6], [8, 7], [8, 8],
[9, 2], [9, 6]]

config = backend.configuration()
n_qubits = config.n_qubits
cmap = config.coupling_map
Expand Down Expand Up @@ -161,7 +176,6 @@ def plot_gate_map(backend, figsize=None,
if ax is None:
fig, ax = plt.subplots(figsize=figsize) # pylint: disable=invalid-name
ax.axis('off')
fig.set_tight_layout(True)

# set coloring
if qubit_color is None:
Expand Down
21 changes: 15 additions & 6 deletions qiskit/visualization/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,15 +721,24 @@ def _build_latex_array(self, aliases=None):
if self.plot_barriers:
qarglist = op.qargs
indexes = [self._get_qubit_index(x) for x in qarglist]
start_bit = self.qubit_list[min(indexes)]
indexes.sort()
if aliases is not None:
qarglist = map(lambda x: aliases[x], qarglist)
start = self.img_regs[start_bit]
span = len(op.qargs) - 1

self._latex[start][column - 1] += " \\barrier[0em]{" + str(
span) + "}"
self._latex[start][column] = "\\qw"
first = last = indexes[0]
for index in indexes[1:]:
if index - 1 == last:
last = index
else:
pos = self.img_regs[self.qubit_list[first]]
self._latex[pos][column - 1] += " \\barrier[0em]{" + str(
last - first) + "}"
self._latex[pos][column] = "\\qw"
first = last = index
pos = self.img_regs[self.qubit_list[first]]
self._latex[pos][column - 1] += " \\barrier[0em]{" + str(
last - first) + "}"
self._latex[pos][column] = "\\qw"
else:
raise exceptions.VisualizationError("bad node data")

Expand Down
Loading

0 comments on commit ef06abe

Please sign in to comment.