qiskit-community / qiskit-nature

Qiskit Nature is an open-source, quantum computing, framework for solving quantum mechanical natural science problems.
https://qiskit-community.github.io/qiskit-nature/
Apache License 2.0
290 stars 197 forks source link

Implements a reverse_map() method for JordanWignerMapper(). #1344

Open MarcoBarroca opened 4 months ago

MarcoBarroca commented 4 months ago

Summary

This implements a reverse_map() method in the JordanWignerMapper(). It allows users to go back from qubit operators into fermionic operators. Completes issue #255.

Also included a unit test.

Details and comments

Instead of using the implementation linked in issue #255 I modified it to use the FermionicOp object for the mapping. Seemed like it would be easier for anyone to understand the code. Both implementations are equivalent.

CLAassistant commented 4 months ago

CLA assistant check
All committers have signed the CLA.

CLAassistant commented 4 months ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

woodsp-ibm commented 4 months ago

I see there are failures which are not of this change but due to a newly released pylint version - I created #1346 as this needs fixing outside of this PR to get CI running again and passing on the code that is already in main here.

MarcoBarroca commented 4 months ago

Sure, I'll fix the mypy error by pushing the complex inside FermionicOp.

MarcoBarroca commented 4 months ago

Included the pylint fixes in this PR. Hope that's'okay. Should fix #1346

woodsp-ibm commented 4 months ago

Included the pylint fixes in this PR. Hope that's'okay.

Would it be too much to ask if you could do them in a separate PR. I think we will need to get the same fixes onto the stable branch so would want to backport the PR. Given this PR introduces a new feature its not something we would backport - that is more for critical fixes where we can do a bug fix release to address things.

Of course once such a separate PR was merged, and the branch here updated, it would all pass.

woodsp-ibm commented 4 months ago

I'll let this run so we can check things anyway if you like. (Once you have a PR that has been merged here it will not longer need a maintainers approval to run - its just on the first PR)

coveralls commented 4 months ago

Pull Request Test Coverage Report for Build 8665226229

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
qiskit_nature/second_q/mappers/jordan_wigner_mapper.py 38 40 95.0%
<!-- Total: 38 40 95.0% -->
Totals Coverage Status
Change from base Build 8662422324: 0.04%
Covered Lines: 8821
Relevant Lines: 10163

💛 - Coveralls
woodsp-ibm commented 4 months ago

Sorry my bad in the suggestion, if you did not correct it was

:class:`JordanWignerMapper

should have been

:class:`.JordanWignerMapper` where it was a . not a second `

MarcoBarroca commented 4 months ago

@woodsp-ibm Let me know if you think the note is okay when you can.

woodsp-ibm commented 4 months ago

@mrossinek Can I get you to take a look at this too.

MarcoBarroca commented 1 month ago

Hey, just wanted an update here. Is there anything I should do about this still?

woodsp-ibm commented 1 month ago

The build errors with mypy are fixed by #1362, which is still open. As far as progressing this hopefully @mrossinek can take a look.