<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _get_v_angle(self, case, B, v_angle_guess, p_businj, iref):
 """ Calculates the voltage phase angles. """

        buses = case.connected_buses

        pv_idxs = [bus._i for bus in buses if bus.type == PV]
        pq_idxs = [bus._i for bus in buses if bus.type == PQ]
        pvpq_idxs = pv_idxs + pq_idxs
        pvpq_rows = [[i] for i in pvpq_idxs]

        # Get the susceptance matrix with the column and row corresponding to
        # the reference bus removed.
        Bpvpq = B[pvpq_rows, pvpq_idxs]

        Bref = B[pvpq_rows, [iref]]

        # Bus active power injections (generation - load) adjusted for phase
        # shifters and real shunts.
        p_surplus = array([case.s_surplus(v).real for v in buses])
        g_shunt = array([bus.g_shunt for bus in buses])
        Pbus = (p_surplus - p_businj - g_shunt) / case.base_mva

        Pbus.shape = len(Pbus), 1

        A = Bpvpq
        b = Pbus[pvpq_idxs] - Bref * v_angle_guess[iref]

#        x, res, rank, s = linalg.lstsq(A.todense(), b)
        x = spsolve(A, b)

        # Insert the reference voltage angle of the slack bus.
        v_angle = r_[x[:iref], v_angle_guess[iref], x[iref:]]

        return v_angle, Pbus[iref]