def expectation_from_state_vector(
        self, state_vector: np.ndarray, qid_map: Mapping[raw_types.Qid, int]
    ) -> float:
        """Compute the expectation value of this ProjectorSum given a state vector.

        Projects the state vector onto the sum of projectors and computes the expectation of the
        measurements.

        Args:
            state_vector: An array representing a valid state vector.
            qid_map: A map from all qubits used in this ProjectorSum to the indices of the qubits
                that `state_vector` is defined over.

        Returns:
            The expectation value of the input state.
        """
        return sum(
            coeff
            * _projector_string_from_projector_dict(vec).expectation_from_state_vector(
                state_vector, qid_map
            )
            for vec, coeff in self._linear_dict.items()
        )
Compute the expectation value of this ProjectorSum given a state vector.

        Projects the state vector onto the sum of projectors and computes the expectation of the
        measurements.

        Args:
            state_vector: An array representing a valid state vector.
            qid_map: A map from all qubits used in this ProjectorSum to the indices of the qubits
                that `state_vector` is defined over.

        Returns:
            The expectation value of the input state.
        
cirq-core/cirq/ops/linear_combinations.py