Skip to content

Commit

Permalink
fix: README test
Browse files Browse the repository at this point in the history
The README test previously failed because the iteration over the
auxiliary operator observables in the ElectronicStructureResult is
currently unable to handle the lack of certain properties which have
always been evaluated for legacy reasons (AngularMomentum,
Magnetization).
Even if we were to default them to an empty list instead of None, while
the zip command would execute normally, no results would be printed
since zip stops after the shortest length.

That being said, fixing ElectronicStructureResult is not the solution
right now in any case, since a user would be unable to manually request
the computation of AngularMomentum and Magnetization before we resolve
the issue ý¿¿¼£�#312
Thus, this commit reverts the exclusion of these auxiliary operators in
the case of `settings.dict_aux_operators`.
  • Loading branch information
mrossinek committed Feb 10, 2022
1 parent 4de53bb commit fcf140a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

from qiskit_nature import QiskitNatureError
from qiskit_nature.constants import BOHR, PERIODIC_TABLE
from qiskit_nature.settings import settings
from qiskit_nature.properties.second_quantization.driver_metadata import DriverMetadata
from qiskit_nature.properties.second_quantization.electronic import (
ElectronicStructureDriverResult,
Expand Down Expand Up @@ -406,9 +405,11 @@ def _construct_driver_result(self) -> ElectronicStructureDriverResult:
self._populate_driver_result_particle_number(driver_result)
self._populate_driver_result_electronic_energy(driver_result)

if not settings.dict_aux_operators:
driver_result.add_property(AngularMomentum(self._nmo * 2))
driver_result.add_property(Magnetization(self._nmo * 2))
# TODO: once https://github.com/Qiskit/qiskit-nature/issues/312 is fixed we can stop adding
# these properties by default.
# if not settings.dict_aux_operators:
driver_result.add_property(AngularMomentum(self._nmo * 2))
driver_result.add_property(Magnetization(self._nmo * 2))

return driver_result

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import numpy as np
from qiskit.utils.validation import validate_min

from qiskit_nature.settings import settings
from qiskit_nature.properties.second_quantization.driver_metadata import DriverMetadata
from qiskit_nature.properties.second_quantization.electronic import (
ElectronicStructureDriverResult,
Expand Down Expand Up @@ -518,9 +517,11 @@ def _construct_driver_result(self) -> ElectronicStructureDriverResult:
self._populate_driver_result_electronic_energy(driver_result)
self._populate_driver_result_electronic_dipole_moment(driver_result)

if not settings.dict_aux_operators:
driver_result.add_property(AngularMomentum(self._mol.nao * 2))
driver_result.add_property(Magnetization(self._mol.nao * 2))
# TODO: once https://github.com/Qiskit/qiskit-nature/issues/312 is fixed we can stop adding
# these properties by default.
# if not settings.dict_aux_operators:
driver_result.add_property(AngularMomentum(self._mol.nao * 2))
driver_result.add_property(Magnetization(self._mol.nao * 2))

return driver_result

Expand Down

0 comments on commit fcf140a

Please sign in to comment.