diff --git a/qiskit/test/mock/fake_backend.py b/qiskit/test/mock/fake_backend.py index 1be914be0dda..6d152b899cdc 100644 --- a/qiskit/test/mock/fake_backend.py +++ b/qiskit/test/mock/fake_backend.py @@ -174,7 +174,12 @@ def dtm(self) -> float: Returns: dtm: The output signal timestep in seconds. """ - return self._conf_dict.get("dtm") + dtm = self._conf_dict.get("dtm") + if dtm is not None: + # converting `dtm` in nanoseconds in configuration file to seconds + return dtm * 1e-9 + else: + return None @property def meas_map(self) -> List[List[int]]: diff --git a/releasenotes/notes/fix-fake-backend-v2-dtm-unit-392a8fe3fcc9b793.yaml b/releasenotes/notes/fix-fake-backend-v2-dtm-unit-392a8fe3fcc9b793.yaml new file mode 100644 index 000000000000..bf01ff7fec13 --- /dev/null +++ b/releasenotes/notes/fix-fake-backend-v2-dtm-unit-392a8fe3fcc9b793.yaml @@ -0,0 +1,8 @@ +--- +fixes: + | + Fixed an issue with :class:`~.BackendV2` based fake backend classes from the + ``qiskit.providers.fake_provider`` module such as ``FakeMontrealV2`` where the + value for the :attr:`~.BackendV2.dtm` attribute were not properly being + converted to seconds. This would cause issues when using these fake backends + with scheduling. diff --git a/test/python/providers/test_fake_backends.py b/test/python/providers/test_fake_backends.py index 2e99feb0033d..da7b6ebd6127 100644 --- a/test/python/providers/test_fake_backends.py +++ b/test/python/providers/test_fake_backends.py @@ -110,6 +110,11 @@ def test_convert_to_target(self, backend): if target.dt is not None: self.assertLess(target.dt, 1e-6) + @data(*FAKE_PROVIDER_FOR_BACKEND_V2.backends()) + def test_backend_v2_dtm(self, backend): + if backend.dtm: + self.assertLess(backend.dtm, 1e-6) + @data(*FAKE_PROVIDER.backends()) def test_to_dict_configuration(self, backend): configuration = backend.configuration()