Skip to content

Commit d4d01c6

Browse files
committed
tests, typo
1 parent a4ac027 commit d4d01c6

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

qiskit/providers/fake_provider/generic_backend_v2.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ def __init__(
161161
None by default.
162162
163163
seed: Optional seed for generation of default values.
164+
164165
pulse_channels: If true, sets default pulse channel information on the backend.
166+
165167
noise_info: If true, associates gates and qubits with default noise information.
166168
"""
167169

@@ -179,7 +181,7 @@ def __init__(
179181
self._control_flow = control_flow
180182
self._calibrate_instructions = calibrate_instructions
181183
self._supported_gates = get_standard_gate_name_mapping()
182-
self._include_errors = noise_info
184+
self._noise_info = noise_info
183185

184186
if calibrate_instructions and not noise_info:
185187
raise QiskitError("Must set parameter noise_info when calibrating instructions.")
@@ -208,6 +210,8 @@ def __init__(
208210
self._build_generic_target()
209211
if pulse_channels:
210212
self._build_default_channels()
213+
else:
214+
self.channels_map = {}
211215

212216
@property
213217
def target(self):
@@ -349,7 +353,7 @@ def _build_generic_target(self):
349353
"""
350354
# the qubit properties are sampled from default ranges
351355
properties = _QUBIT_PROPERTIES
352-
if not self._include_errors:
356+
if not self._noise_info:
353357
self._target = Target(
354358
description=f"Generic Target with {self._num_qubits} qubits",
355359
num_qubits=self._num_qubits,
@@ -398,7 +402,7 @@ def _build_generic_target(self):
398402
f"Provided basis gate {name} needs more qubits than {self.num_qubits}, "
399403
f"which is the size of the backend."
400404
)
401-
if self._include_errors:
405+
if self._noise_info:
402406
noise_params = self._get_noise_defaults(name, gate.num_qubits)
403407
self._add_noisy_instruction_to_target(gate, noise_params, calibration_inst_map)
404408
else:

test/python/providers/fake_provider/test_generic_backend_v2.py

+20
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@ def test_ccx_2Q(self):
4545
with self.assertRaises(QiskitError):
4646
GenericBackendV2(num_qubits=2, basis_gates=["ccx", "id"])
4747

48+
def test_calibration_no_noise_info(self):
49+
"""Test failing with a backend with calibration and no noise info"""
50+
with self.assertRaises(QiskitError):
51+
GenericBackendV2(
52+
num_qubits=2,
53+
basis_gates=["ccx", "id"],
54+
calibrate_instructions=True,
55+
noise_info=False,
56+
)
57+
58+
def test_no_noise(self):
59+
"""Test no noise info when parameter is false"""
60+
backend = GenericBackendV2(num_qubits=2, noise_info=False)
61+
self.assertEqual(backend.target.qubit_properties, None)
62+
63+
def test_no_pulse_channels(self):
64+
"""Test no/empty pulse channels when parameter is false"""
65+
backend = GenericBackendV2(num_qubits=2, pulse_channels=False)
66+
self.assertTrue(len(backend.channels_map) == 0)
67+
4868
def test_operation_names(self):
4969
"""Test that target basis gates include "delay", "measure" and "reset" even
5070
if not provided by user."""

0 commit comments

Comments
 (0)