qiskit_nature/properties/second_quantization/electronic/integrals/two_body_electronic_integrals.py
def to_spin(self) -> np.ndarray:
        """Transforms the integrals into the special ``ElectronicBasis.SO`` basis.

        Returns:
            A single matrix containing the ``n-body`` integrals in the spin orbital basis.
        """
        if self._basis == ElectronicBasis.SO:
            return self._matrices  # type: ignore

        so_matrix = np.zeros([2 * s for s in self._matrices[0].shape])
        one_indices = (
            (0, 0, 0, 0),  # alpha-alpha-spin
            (0, 1, 1, 0),  # beta-alpha-spin
            (1, 1, 1, 1),  # beta-beta-spin
            (1, 0, 0, 1),  # alpha-beta-spin
        )
        alpha_beta_spin_idx = 3
        for idx, (ao_mat, one_idx) in enumerate(zip(self._matrices, one_indices)):
            if ao_mat is None:
                if idx == alpha_beta_spin_idx:
                    ao_mat = self._matrices[0] if self._matrices[1] is None else self._matrices[1].T
                else:
                    ao_mat = self._matrices[0]
            phys_matrix = np.einsum(self.EINSUM_CHEM_TO_PHYS, ao_mat)
            kron = np.zeros((2, 2, 2, 2))
            kron[one_idx] = 1
            so_matrix -= 0.5 * np.kron(kron, phys_matrix)

        return np.where(np.abs(so_matrix) > self._threshold, so_matrix, 0.0)
Transforms the integrals into the special ``ElectronicBasis.SO`` basis.

        Returns:
            A single matrix containing the ``n-body`` integrals in the spin orbital basis.
        
Transforms the integrals into the special ``ElectronicBasis.SO`` basis.
Transforms the integrals into the special ` ` ElectronicBasis . SO ` ` basis .
def to_spin(self) -> np.ndarray:
        if self._basis == ElectronicBasis.SO:
            return self._matrices  
        so_matrix = np.zeros([2 * s for s in self._matrices[0].shape])
        one_indices = (
            (0, 0, 0, 0),  
            (0, 1, 1, 0),  
            (1, 1, 1, 1),  
            (1, 0, 0, 1),  
        )
        alpha_beta_spin_idx = 3
        for idx, (ao_mat, one_idx) in enumerate(zip(self._matrices, one_indices)):
            if ao_mat is None:
                if idx == alpha_beta_spin_idx:
                    ao_mat = self._matrices[0] if self._matrices[1] is None else self._matrices[1].T
                else:
                    ao_mat = self._matrices[0]
            phys_matrix = np.einsum(self.EINSUM_CHEM_TO_PHYS, ao_mat)
            kron = np.zeros((2, 2, 2, 2))
            kron[one_idx] = 1
            so_matrix -= 0.5 * np.kron(kron, phys_matrix)
        return np.where(np.abs(so_matrix) > self._threshold, so_matrix, 0.0)
def to_spin ( self ) -> np . ndarray : if self . _basis == ElectronicBasis . SO : return self . _matrices so_matrix = np . zeros ( [ 2 * s for s in self . _matrices [ 0 ] . shape ] ) one_indices = ( ( 0 , 0 , 0 , 0 ) , ( 0 , 1 , 1 , 0 ) , ( 1 , 1 , 1 , 1 ) , ( 1 , 0 , 0 , 1 ) , ) alpha_beta_spin_idx = 3 for idx , ( ao_mat , one_idx ) in enumerate ( zip ( self . _matrices , one_indices ) ) : if ao_mat is None : if idx == alpha_beta_spin_idx : ao_mat = self . _matrices [ 0 ] if self . _matrices [ 1 ] is None else self . _matrices [ 1 ] . T else : ao_mat = self . _matrices [ 0 ] phys_matrix = np . einsum ( self . EINSUM_CHEM_TO_PHYS , ao_mat ) kron = np . zeros ( ( 2 , 2 , 2 , 2 ) ) kron [ one_idx ] = 1 so_matrix -= 0.5 * np . kron ( kron , phys_matrix ) return np . where ( np . abs ( so_matrix ) > self . _threshold , so_matrix , 0.0 )
Transforms the integrals into the special ``ElectronicBasis.SO`` basis.
Transforms the integrals into the special ` ` ElectronicBasis . SO ` ` basis .
"""Transforms the integrals into the special ``ElectronicBasis.SO`` basis.

        Returns:
            A single matrix containing the ``n-body`` integrals in the spin orbital basis.
        """ # type: ignore # alpha-alpha-spin # beta-alpha-spin # beta-beta-spin # alpha-beta-spin
A single matrix containing the ``n-body`` integrals in the spin orbital basis.
A single matrix containing the ` ` n - body ` ` integrals in the spin orbital basis .
self