def test_minimal_active_space(self):
        """Test a minimal active space manually."""
        driver = HDF5Driver(hdf5_input=self.get_resource_path(
            "H2_631g.hdf5", "transformers/second_quantization/electronic"))
        q_molecule = driver.run()

        trafo = ActiveSpaceTransformer(num_electrons=2,
                                       num_molecular_orbitals=2)
        q_molecule_reduced = trafo.transform(q_molecule)

        expected = QMolecule()
        expected.mo_onee_ints = np.asarray([[-1.24943841, 0.0],
                                            [0.0, -0.547816138]])
        expected.mo_eri_ints = np.asarray([
            [
                [[0.652098466, 0.0], [0.0, 0.433536565]],
                [[0.0, 0.0794483182], [0.0794483182, 0.0]],
            ],
            [
                [[0.0, 0.0794483182], [0.0794483182, 0.0]],
                [[0.433536565, 0.0], [0.0, 0.385524695]],
            ],
        ])

        expected.x_dip_mo_ints = np.zeros((2, 2))
        expected.y_dip_mo_ints = np.zeros((2, 2))
        expected.z_dip_mo_ints = np.asarray([[0.69447435, -1.01418298],
                                             [-1.01418298, 0.69447435]])

        expected.energy_shift["ActiveSpaceTransformer"] = 0.0
        expected.x_dip_energy_shift["ActiveSpaceTransformer"] = 0.0
        expected.y_dip_energy_shift["ActiveSpaceTransformer"] = 0.0
        expected.z_dip_energy_shift["ActiveSpaceTransformer"] = 0.0

        self.assertQMolecule(q_molecule_reduced, expected)
    def test_arbitrary_active_orbitals(self):
        """Test manual selection of active orbital indices."""
        driver = HDF5Driver(hdf5_input=self.get_resource_path('H2_631g.hdf5', 'transformers'))
        q_molecule = driver.run()

        trafo = ActiveSpaceTransformer(num_electrons=2, num_molecular_orbitals=2,
                                       active_orbitals=[0, 2])
        q_molecule_reduced = trafo.transform(q_molecule)

        expected = QMolecule()
        expected.mo_onee_ints = np.asarray([[-1.24943841, -0.16790838], [-0.16790838, -0.18307469]])
        expected.mo_eri_ints = np.asarray([[[[0.65209847, 0.16790822], [0.16790822, 0.53250905]],
                                            [[0.16790822, 0.10962908], [0.10962908, 0.11981429]]],
                                           [[[0.16790822, 0.10962908], [0.10962908, 0.11981429]],
                                            [[0.53250905, 0.11981429], [0.11981429, 0.46345617]]]])

        expected.x_dip_mo_ints = np.zeros((2, 2))
        expected.y_dip_mo_ints = np.zeros((2, 2))
        expected.z_dip_mo_ints = np.asarray([[0.69447435, 0.0], [0.0, 0.69447435]])

        expected.energy_shift['ActiveSpaceTransformer'] = 0.0
        expected.x_dip_energy_shift['ActiveSpaceTransformer'] = 0.0
        expected.y_dip_energy_shift['ActiveSpaceTransformer'] = 0.0
        expected.z_dip_energy_shift['ActiveSpaceTransformer'] = 0.0

        self.assertQMolecule(q_molecule_reduced, expected)