Skip to content

Commit

Permalink
format import in aerbackend
Browse files Browse the repository at this point in the history
  • Loading branch information
hhorii committed Mar 30, 2021
1 parent 5c45c50 commit 12db16f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions qiskit/providers/aer/backends/aerbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@
from qiskit.qobj import QasmQobj, PulseQobj
from qiskit.compiler import assemble

from qiskit.providers.aer.profile import get_performance_options

from ..aerjob import AerJob
from ..aererror import AerError
from ..profile import get_performance_options

# Logger
logger = logging.getLogger(__name__)
Expand Down
18 changes: 9 additions & 9 deletions qiskit/providers/aer/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ def _set_option(option_name, value, persist):
filename = os.getenv('QISKIT_SETTINGS', user_config.DEFAULT_FILENAME)
if os.path.isfile(filename):
config.read(filename)
if section_name not in config.sections():
config.add_section(section_name)
config.set(section_name, option_name, str(value))
with open(filename, "w+") as config_file:
config.write(config_file)
if section_name not in config.sections():
config.add_section(section_name)
config.set(section_name, option_name, str(value))
with open(filename, "w+") as config_file:
config.write(config_file)

@staticmethod
def _get_options_from_file(option2type):
Expand Down Expand Up @@ -337,7 +337,8 @@ def profile_fusion_threshold(min_qubits=10, max_qubits=20, ntrials=10,
raise AerError(f'Unable to find threshold in range [{min_qubits}, {max_qubits}]')


def profile_fusion_costs(num_qubits, ntrials=10, backend_options=None, gpu=False, diagonal=False):
def profile_fusion_costs(num_qubits, ntrials=10, backend_options=None, gpu=False, diagonal=False,
return_ratio=True):
"""Evaluate optimal costs in cost-based fusion for current system."""
profile_opts = {'method': 'statevector',
'max_parallel_experiments': 1,
Expand Down Expand Up @@ -380,8 +381,7 @@ def profile_fusion_costs(num_qubits, ntrials=10, backend_options=None, gpu=False
profile_circuit,
None))

costs = []
for target in range(0, 5):
costs.append(all_gate_time[target] / all_gate_time[0])
base_line = all_gate_time[0] if return_ratio else 1.0
costs = [gate_time / base_line for gate_time in all_gate_time]

return costs
2 changes: 1 addition & 1 deletion test/terra/backends/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from qiskit.providers.aer import QasmSimulator
from qiskit.providers.aer.profile import profile_performance_options, clear_performance_options

#@unittest.skip("Remove this for manual run")
@unittest.skip("Remove this for manual run")
class TestProfileQasmSimulator(common.QiskitAerTestCase):


Expand Down

0 comments on commit 12db16f

Please sign in to comment.