Skip to content

Add missing dict conversion in backconfiguration class#4124

Merged
mergify[bot] merged 15 commits into
Qiskit:masterfrom
mtreinish:fix-uchannel-lo
Apr 21, 2020
Merged

Add missing dict conversion in backconfiguration class#4124
mergify[bot] merged 15 commits into
Qiskit:masterfrom
mtreinish:fix-uchannel-lo

Conversation

@mtreinish
Copy link
Copy Markdown
Member

Summary

After #4016 has merged a missed edge case in the handling of to_dict()
and from_dict() for PulseBackendConfiguration was discovered via the aer
unit tests. The u_channel_lo attribute is a nested object and needs to
call UChannelLO's to_dict() and from_dict() methods in those respective
calls. However, this conversion was not being done. This commit corrects
the oversight.

Details and comments

After Qiskit#4016 has merged a missed edge case in the handling of to_dict()
and from_dict() for PulseBackendConfiguration was discovered via the aer
unit tests. The u_channel_lo attribute is a nested object and needs to
call UChannelLO's to_dict() and from_dict() methods in those respective
calls. However, this conversion was not being done. This commit corrects
the oversight.
There was an issue in the pulse defaults to_dict() method too where the
converters attribute was incorrectly attempted to be output as a
property in the output dictionary. This was incorrect and it just a
helper there constructed based on other input. So outputting it with the
dictionary was incorrect. This commit corrects this oversight.
Copy link
Copy Markdown
Contributor

@jyu00 jyu00 left a comment

Choose a reason for hiding this comment

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

LGTM, other than the type hint mentioned below.

Comment thread qiskit/providers/models/backendconfiguration.py
@chriseclectic
Copy link
Copy Markdown
Member

This still doesn't quite fix the Aer tests. Running tests on this branch there is still one test failure with

======================================================================
ERROR: test_control_channel_labels_from_backend (test.terra.openpulse.test_system_models.TestPulseSystemModel)
Test correct importing of backend control channel description.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "qiskit-aer/test/terra/openpulse/test_system_models.py", line 106, in test_control_channel_labels_from_backend
    system_model = PulseSystemModel.from_backend(backend)
  File "qiskit-aer/qiskit/providers/aer/pulse/pulse_system_model.py", line 159, in from_backend
    u_string += str(scale[0] + scale[1] * 1j) + 'q' + str(q_idx)
TypeError: 'complex' object is not subscriptable

I'm guessing this is to do with JSON storing complex as a pair vs using complex in python dict?

@mtreinish
Copy link
Copy Markdown
Member Author

@chriseclectic yeah, that looks like the pulse system model was assuming [real, imag]. That should be fixed by: Qiskit/qiskit-aer#694

mtreinish added a commit to mtreinish/qiskit-aer that referenced this pull request Apr 14, 2020
As fall out from Qiskit/qiskit#4016 there was a bug in the
to_dict() method of the backend configuration that was resulting in
UChannelLO objects not getting converted to their dict form in the
output of to_dict(). While this is being fixed in
Qiskit/qiskit#4124 this commit side steps the issue by adapting
the access patterns in the pulse system model to rely on class attribute
access and getattr() instead of dict access and get().
mtreinish added a commit to mtreinish/qiskit-aer that referenced this pull request Apr 14, 2020
As fall out from Qiskit/qiskit#4016 there was a bug in the
to_dict() method of the backend configuration that was resulting in
UChannelLO objects not getting converted to their dict form in the
output of to_dict(). While this is being fixed in
Qiskit/qiskit#4124 this commit side steps the issue by adapting
the access patterns in the pulse system model to rely on class attribute
access and getattr() instead of dict access and get().
chriseclectic added a commit to Qiskit/qiskit-aer that referenced this pull request Apr 14, 2020
* Avoid to_dict() when possible in pulse system model

As fall out from Qiskit/qiskit#4016 there was a bug in the
to_dict() method of the backend configuration that was resulting in
UChannelLO objects not getting converted to their dict form in the
output of to_dict(). While this is being fixed in
Qiskit/qiskit#4124 this commit side steps the issue by adapting
the access patterns in the pulse system model to rely on class attribute
access and getattr() instead of dict access and get().

Co-authored-by: Christopher J. Wood <cjwood@us.ibm.com>
hhorii pushed a commit to hhorii/qiskit-aer that referenced this pull request Apr 16, 2020
* Avoid to_dict() when possible in pulse system model

As fall out from Qiskit/qiskit#4016 there was a bug in the
to_dict() method of the backend configuration that was resulting in
UChannelLO objects not getting converted to their dict form in the
output of to_dict(). While this is being fixed in
Qiskit/qiskit#4124 this commit side steps the issue by adapting
the access patterns in the pulse system model to rely on class attribute
access and getattr() instead of dict access and get().

Co-authored-by: Christopher J. Wood <cjwood@us.ibm.com>
chriseclectic added a commit to chriseclectic/qiskit-aer that referenced this pull request Apr 20, 2020
* Avoid to_dict() when possible in pulse system model

As fall out from Qiskit/qiskit#4016 there was a bug in the
to_dict() method of the backend configuration that was resulting in
UChannelLO objects not getting converted to their dict form in the
output of to_dict(). While this is being fixed in
Qiskit/qiskit#4124 this commit side steps the issue by adapting
the access patterns in the pulse system model to rely on class attribute
access and getattr() instead of dict access and get().

Co-authored-by: Christopher J. Wood <cjwood@us.ibm.com>
@mtreinish mtreinish added this to the 0.14 milestone Apr 20, 2020
Copy link
Copy Markdown
Contributor

@jyu00 jyu00 left a comment

Choose a reason for hiding this comment

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

LGTM

@mergify mergify Bot merged commit b97f6c6 into Qiskit:master Apr 21, 2020
@mtreinish mtreinish deleted the fix-uchannel-lo branch April 21, 2020 19:51
faisaldebouni pushed a commit to faisaldebouni/qiskit-terra that referenced this pull request Aug 5, 2020
* Add missing dict conversion in backconfiguration class

After Qiskit#4016 has merged a missed edge case in the handling of to_dict()
and from_dict() for PulseBackendConfiguration was discovered via the aer
unit tests. The u_channel_lo attribute is a nested object and needs to
call UChannelLO's to_dict() and from_dict() methods in those respective
calls. However, this conversion was not being done. This commit corrects
the oversight.

* Fix pulse defaults to dict

There was an issue in the pulse defaults to_dict() method too where the
converters attribute was incorrectly attempted to be output as a
property in the output dictionary. This was incorrect and it just a
helper there constructed based on other input. So outputting it with the
dictionary was incorrect. This commit corrects this oversight.

* Fix typo and tests

* Fix typo in tests

* Remove another extra defaults attribute

* Update type hint

Co-authored-by: Christopher J. Wood <cjwood@us.ibm.com>
ElePT pushed a commit to ElePT/qiskit-ibm-provider that referenced this pull request Oct 9, 2023
…#4124)

* Add missing dict conversion in backconfiguration class

After Qiskit/qiskit#4016 has merged a missed edge case in the handling of to_dict()
and from_dict() for PulseBackendConfiguration was discovered via the aer
unit tests. The u_channel_lo attribute is a nested object and needs to
call UChannelLO's to_dict() and from_dict() methods in those respective
calls. However, this conversion was not being done. This commit corrects
the oversight.

* Fix pulse defaults to dict

There was an issue in the pulse defaults to_dict() method too where the
converters attribute was incorrectly attempted to be output as a
property in the output dictionary. This was incorrect and it just a
helper there constructed based on other input. So outputting it with the
dictionary was incorrect. This commit corrects this oversight.

* Fix typo and tests

* Fix typo in tests

* Remove another extra defaults attribute

* Update type hint

Co-authored-by: Christopher J. Wood <cjwood@us.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants