Skip to content

Commit

Permalink
Fixing #81 in mapper (#105)
Browse files Browse the repository at this point in the history
* if the first layer is trivial, it should not be ignored. Fixes #81
  • Loading branch information
1ucian0 authored and atilag committed Oct 17, 2017
1 parent 5a3fda3 commit f49975e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion qiskit/_openquantumcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def compile(qasm_circuit, basis_gates='u1,u2,u3,cx,id', coupling_map=None,
initial_layout (dict): A mapping of qubit to qubit::
{
("q", strart(int)): ("q", final(int)),
("q", start(int)): ("q", final(int)),
...
}
eg.
Expand Down
11 changes: 2 additions & 9 deletions qiskit/mapper/_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ def swap_mapper(circuit_graph, coupling_graph,
# Schedule the input circuit
layerlist = circuit_graph.layers()
logger.debug("schedule:")
for i in range(len(layerlist)):
logger.debug(" %d: %s", i, layerlist[i]["partition"])
for i,v in enumerate(layerlist):
logger.debug(" %d: %s", (i, v["partition"]))

This comment has been minimized.

Copy link
@cclauss

cclauss Nov 15, 2017

Contributor

The parens added in this change should be removed.

  • logger.debug(" %d: %s", (i, v["partition"])) # should become...
  • logger.debug(" %d: %s", i, v["partition"])

Logger.debug() is expecting three params but only getting two which is causing pylint to say:

  • ************* Module qiskit.mapper._mapping
  • E:336, 8: Not enough arguments for logging format string (logging-too-few-args)

This comment has been minimized.

Copy link
@diego-plan9

diego-plan9 Nov 15, 2017

Member

Sounds good!


if initial_layout is not None:
# Check the input layout
Expand Down Expand Up @@ -372,13 +372,6 @@ def swap_mapper(circuit_graph, coupling_graph,
logger.debug("swap_mapper: success_flag=%s,best_d=%s,trivial_flag=%s",
success_flag, str(best_d), trivial_flag)

# If this layer is only single-qubit gates,
# and we have yet to see multi-qubit gates,
# continue to the next iteration
if trivial_flag and first_layer:
logger.debug("swap_mapper: skip to next layer")
continue

# If this fails, try one gate at a time in this layer
if not success_flag:
logger.debug("swap_mapper: failed, layer %d, "
Expand Down

0 comments on commit f49975e

Please sign in to comment.