Skip to content
This repository was archived by the owner on Dec 7, 2021. It is now read-only.

Commit 1264bc2

Browse files
mrossinekCryoris
andauthored
Ground State Interface: Minor cleanups (#1357)
* Expose NumPyMinimumEigensolverFactory one module below This is inline with the other factories being exposed too. * Fix deprecation warning paths * Add spin restriction to default fermionic filter * Rename test_mes_gsc_calculation to test_groundstate_eigensolver * Remove deprecation warnings in Hamiltonian-Enums Co-authored-by: Julien Gacon <[email protected]>
1 parent b79ef86 commit 1264bc2

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

qiskit/chemistry/algorithms/ground_state_solvers/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@
1515
from .ground_state_solver import GroundStateSolver
1616
from .adapt_vqe import AdaptVQE
1717
from .ground_state_eigensolver import GroundStateEigensolver
18-
from .minimum_eigensolver_factories import MinimumEigensolverFactory, VQEUCCSDFactory
18+
from .minimum_eigensolver_factories import (MinimumEigensolverFactory,
19+
NumPyMinimumEigensolverFactory,
20+
VQEUCCSDFactory)
21+
1922

2023
__all__ = ['GroundStateSolver',
2124
'AdaptVQE',
2225
'GroundStateEigensolver',
2326
'MinimumEigensolverFactory',
27+
'NumPyMinimumEigensolverFactory',
2428
'VQEUCCSDFactory'
2529
]

qiskit/chemistry/core/hamiltonian.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,12 @@
3333

3434
class TransformationType(Enum):
3535
""" Transformation Type enum """
36-
warnings.warn('The chemistry.core.TransformationType class is deprecated as of Qiskit Aqua '
37-
'0.8.0 and will be removed no earlier than 3 months after the release date. '
38-
'Instead, the '
39-
'chemistry.qubit_transformatons.fermionic_transformation.TransformationType can '
40-
'be used.', DeprecationWarning, stacklevel=2)
4136
FULL = 'full'
4237
PARTICLE_HOLE = 'particle_hole'
4338

4439

4540
class QubitMappingType(Enum):
4641
""" QubitMappingType enum """
47-
warnings.warn('The chemistry.core.QubitMappingType class is deprecated as of Qiskit Aqua '
48-
'0.8.0 and will be removed no earlier than 3 months after the release date. '
49-
'Instead, the '
50-
'chemistry.qubit_transformatons.fermionic_transformation.QubitMappingType can '
51-
'be used.', DeprecationWarning, stacklevel=2)
5242
JORDAN_WIGNER = 'jordan_wigner'
5343
PARITY = 'parity'
5444
BRAVYI_KITAEV = 'bravyi_kitaev'

qiskit/chemistry/transformations/fermionic_transformation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,10 @@ def get_default_filter_criterion(self) -> Optional[Callable[[Union[List, np.ndar
474474
def filter_criterion(self, eigenstate, eigenvalue, aux_values):
475475
# the first aux_value is the evaluated number of particles
476476
num_particles_aux = aux_values[0][0]
477-
return np.isclose(sum(self.molecule_info['num_particles']), num_particles_aux)
477+
# the second aux_value is the total angular momentum which (for singlets) should be zero
478+
total_angular_momentum_aux = aux_values[1][0]
479+
return np.isclose(sum(self.molecule_info['num_particles']), num_particles_aux) and \
480+
np.isclose(0., total_angular_momentum_aux)
478481

479482
return partial(filter_criterion, self)
480483

test/chemistry/test_mes_gsc_calculation.py renamed to test/chemistry/test_groundstate_eigensolver.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# copyright notice, and modified files need to carry a notice indicating
1111
# that they have been altered from the originals.
1212

13-
""" Test MinimumEigensovler ground state calculation """
13+
""" Test GroundStateEigensolver """
1414

1515
import unittest
1616

@@ -27,8 +27,8 @@
2727
(VQEUCCSDFactory, NumPyMinimumEigensolverFactory)
2828

2929

30-
class TestMESGSCCalculation(QiskitChemistryTestCase):
31-
""" Test MinimumEigensovler ground state calculation """
30+
class TestGroundStateEigensolver(QiskitChemistryTestCase):
31+
""" Test GroundStateEigensolver """
3232

3333
def setUp(self):
3434
super().setUp()
@@ -52,6 +52,13 @@ def test_npme(self):
5252
res = calc.solve(self.driver)
5353
self.assertAlmostEqual(res.energy, self.reference_energy, places=6)
5454

55+
def test_npme_with_default_filter(self):
56+
""" Test NumPyMinimumEigensolver with default filter """
57+
solver = NumPyMinimumEigensolverFactory(use_default_filter_criterion=True)
58+
calc = GroundStateEigensolver(self.transformation, solver)
59+
res = calc.solve(self.driver)
60+
self.assertAlmostEqual(res.energy, self.reference_energy, places=6)
61+
5562
def test_vqe_uccsd(self):
5663
""" Test VQE UCCSD case """
5764
solver = VQEUCCSDFactory(QuantumInstance(BasicAer.get_backend('statevector_simulator')))

0 commit comments

Comments
 (0)