Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fake backend v2 dtm unit #8019

Merged
merged 9 commits into from
May 4, 2022
7 changes: 6 additions & 1 deletion qiskit/test/mock/fake_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions test/python/providers/test_fake_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Comment on lines +113 to +117
Copy link
Collaborator Author

@HuangJunye HuangJunye May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test for dtm cannot be combined with dt (like test_to_dict_configuration) because dtm is not part of the target. But I am not sure creating a specific test just for dtm is a good practice or not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mtreinish What do you think about the test? Is the function name too specific? Does this test belong to this file or should it be in the test_fake_backend_v2.py?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine here and is a reasonable test to make sure we've got the unit conversion right.

@data(*FAKE_PROVIDER.backends())
def test_to_dict_configuration(self, backend):
configuration = backend.configuration()
Expand Down