Ejemplo n.º 1
0
    def test_bitstring_invalid_input(self):
        """Test passing invalid input raises."""

        with self.subTest('too many particles'):
            with self.assertRaises(ValueError):
                _ = hartree_fock_bitstring(4, (3, 3))

        with self.subTest('too few orbitals'):
            with self.assertRaises(ValueError):
                _ = hartree_fock_bitstring(-1, (2, 2))
    def test_bitstring_invalid_input(self):
        """Test passing invalid input raises."""

        with self.subTest('too many particles'):
            with self.assertRaises(ValueError):
                _ = hartree_fock_bitstring(4, 4, 'jordan-wigner')

        with self.subTest('too few orbitals'):
            with self.assertRaises(ValueError):
                _ = hartree_fock_bitstring(-1, 4, 'parity', True)

        with self.subTest('invalid qubit mapping'):
            with self.assertRaises(ValueError):
                _ = hartree_fock_bitstring(4, 2, 'parit', True)
    def symmetry_sector_locator(self, z2_symmetries: Z2Symmetries) -> Optional[List[int]]:
        """Given the detected Z2Symmetries can determine the correct sector of the tapered
        operators so the correct one can be returned

        Args:
            z2_symmetries: the z2 symmetries object.

        Returns:
            The sector of the tapered operators with the problem solution.
        """
        q_molecule = cast(QMolecule, self._molecule_data_transformed)

        hf_bitstr = hartree_fock_bitstring(
            num_spin_orbitals=2 * q_molecule.num_molecular_orbitals,
            num_particles=self.num_particles)
        sector_locator = self._pick_sector(z2_symmetries, hf_bitstr)

        return sector_locator
Ejemplo n.º 4
0
 def test_bitstring(self):
     """Simple test for the bitstring function."""
     bitstr = hartree_fock_bitstring(4, (1, 1))
     self.assertTrue(all(bitstr == np.array([True, False, True, False])))
 def test_bitstring(self):
     """Simple test for the bitstring function."""
     bitstr = hartree_fock_bitstring(4, 2, 'parity', True)
     self.assertTrue(all(
         bitstr[::-1] == np.array([True, False])))  # big endian notation