Based on makeB.m from MATPOWER by Ray Zimmerman, developed at
        PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
        information.

        @param method: Specify "XB" or "BX" method.
        @type method: string

        @rtype: tuple
        @return: Two matrices, B prime and B double prime, used in the fast
        decoupled power flow solver.

def makeB(self, buses=None, branches=None, method="XB"):
        """ Based on makeB.m from MATPOWER by Ray Zimmerman, developed at
        PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more
        information.

        @param method: Specify "XB" or "BX" method.
        @type method: string

        @rtype: tuple
        @return: Two matrices, B prime and B double prime, used in the fast
        decoupled power flow solver.
        """
        buses = self.connected_buses if buses is None else buses
        branches = self.online_branches if branches is None else branches

        B_buses = copy.deepcopy(buses) # modify bus copies
        Bp_branches = copy.deepcopy(branches) # modify branch copies
        Bpp_branches = copy.deepcopy(branches)

        for bus in B_buses:
            bus.b_shunt = 0.0
        for branch in Bp_branches:
            branch.b = 0.0
            branch.ratio = 1.0
            if method == "XB":
                branch.r = 0.0

        Yp, _, _ = self.getYbus(B_buses, Bp_branches)

        for branch in Bpp_branches:
            branch.phase_shift = 0.0
            if method == "BX":
                branch.r = 0.0

        Ypp, _, _ = self.getYbus(B_buses, Bpp_branches)

        del B_buses
        del Bp_branches

        return -Yp.imag, -Ypp.imag