Skip to content

Commit 6443a75

Browse files
authored
Add fix test
1 parent dac65bb commit 6443a75

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/python/circuit/test_scheduled_circuit.py

+31
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,38 @@ def test_estimate_duration_with_long_delay(self, unit):
534534
"P": expected_in_sec / 1e15,
535535
}
536536
self.assertEqual(duration, expected_val[unit])
537+
@data("s", "dt", "f", "p", "n", "u", "µ", "m", "k", "M", "G", "T", "P")
538+
def test_estimate_duration_with_dt_float(self, unit):
539+
# This is not a valid use case, but it is still expressible currently
540+
# since we don't disallow fractional dt values. This should not be assumed
541+
# to be a part of an api contract. If there is a refactor and this test
542+
# breaks remove the test it is not valid. This was only added to provide
543+
# explicit test coverage for a rust code path.
544+
backend = GenericBackendV2(num_qubits=3, seed=42)
537545

546+
circ = QuantumCircuit(3)
547+
circ.cx(0, 1)
548+
circ.measure_all()
549+
circ.delay(1.23e15, 2, unit="dt")
550+
circuit_dt = transpile(circ, backend, scheduling_method="asap")
551+
duration = circuit_dt.estimate_duration(backend.target, unit=unit)
552+
expected_in_sec = 273060.0000013993
553+
expected_val = {
554+
"s": expected_in_sec,
555+
"dt": int(expected_in_sec / backend.target.dt),
556+
"f": expected_in_sec / 1e-15,
557+
"p": expected_in_sec / 1e-12,
558+
"n": expected_in_sec / 1e-9,
559+
"u": expected_in_sec / 1e-6,
560+
"µ": expected_in_sec / 1e-6,
561+
"m": expected_in_sec / 1e-3,
562+
"k": expected_in_sec / 1e3,
563+
"M": expected_in_sec / 1e6,
564+
"G": expected_in_sec / 1e9,
565+
"T": expected_in_sec / 1e12,
566+
"P": expected_in_sec / 1e15,
567+
}
568+
self.assertEqual(duration, expected_val[unit])
538569
def test_estimate_duration_invalid_unit(self):
539570
backend = GenericBackendV2(num_qubits=3, seed=42)
540571

0 commit comments

Comments
 (0)