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

Unittest not running because QiskitTestCase class is removed in Qiskit 1.0. #98

Open
robotastray opened this issue Sep 3, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@robotastray
Copy link
Contributor

robotastray commented Sep 3, 2024

Information

  • Qiskit Cold atoms version:latest
  • Python version: Python 3.12.3
  • Operating system: macOS

What is the current behavior?

As per issue #97, the qiskit-terra (>=0.17.1) dependencies need to be removed. I have also noticed that the unittest files depend on the qiskit.test class QiskitTestCase, which is not available in Qiskit 1.0 and beyond.

Steps to reproduce the problem

  • Create a virtual environment
  • Install the latest version of Qiskit 1.0 and necessary qiskit libraries (e.g. qiskit_are, qiskit-nature, qiskit-algorithms)
  • Update lines 26 and 27 of qiskit_cold_atom/applications/time_evolution_solver.py to:
            from qiskit_algorithms import TimeEvolutionProblem
            from qiskit_algorithms.time_evolvers import TrotterQRTE

(this change will ensure the use of the qiskit-algorithm rather than the deprecated qiskit.algorithm.

  • run python -m unittest in the root folder
  • The error displayed is:
            From qiskit.test import QiskitTestCase
        ModuleNotFoundError: No module named 'qiskit.test'

This is because qiskit.test class QiskitTestCase is not defined in Qiskit 1.0

What is the expected behavior?

Unittests should run and either pass or fail.

Suggested solutions

[update at on 3/09/24 at 16:43GMT on possible solution]

  • remove qiskit.test from qiskit-cold-atom and use an alternative method

I think this problem should be addressed before (or while) resolving issue #97

@robotastray robotastray added the bug Something isn't working label Sep 3, 2024
@robotastray robotastray changed the title Unittest not running because QiskitTestCase class is not defined in Qiskit 1.0. Unittest not running because QiskitTestCase class is removed in Qiskit 1.0. Sep 3, 2024
@1ucian0
Copy link
Contributor

1ucian0 commented Sep 3, 2024

Indeed, QiskitTestCase was removed in Qiskit/qiskit#11445. It can probably just be replaced by unittest.TestCase.

@robotastray
Copy link
Contributor Author

Hello @1ucian0 okay! I will try this and open a PR when done.

@robotastray
Copy link
Contributor Author

robotastray commented Sep 15, 2024

Hello, @1ucian0 is there any documentation explaining how to substitute iteration of CircuitInstruction in Qiskit 2.0 using the operation, qubits and clbits named attributes? I am searching for it but cannot find it anywhere.

update:I was able to find the documentation and I think I resolved the problem.

@1ucian0
Copy link
Contributor

1ucian0 commented Sep 16, 2024

I think I resolved the problem.

Great! want to push somewhere? I could have a look.

@robotastray
Copy link
Contributor Author

robotastray commented Sep 16, 2024

Hello, I only fixed that particular issue, I still have some others to solve (I will also need to review the formatting before opening a PR). They will all be on this branch

https://github.com/robotAstray/qiskit-cold-atom/tree/fix-qiskit-terra-dependencies

@robotastray
Copy link
Contributor Author

robotastray commented Sep 16, 2024

@1ucian0 Since we need to move from BackendV1 to BackendV2, some changes are necessary in the definition of the class FermionSimulator(), which inherits from the class BaseFermionBackend(), which takes a BackendV2 as an argument.
FermionSimlutor will need two additional methods:

  1. def max_circuits()
  2. def target()

What would be the requirements for (1) and the instructions for (2)?

something like the code used elsewhere?

    @property
    def max_circuits(self) -> None:
        return None

    @property
    def target(self) -> Target:
        if not self._target:
            self._target = self._build_basic_target()
        return self._target

update: these methods should also be implemented in class SpinSimulator.

(I plan to resolve both issue #98 and issue #97 in one PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants