'Convert this instance of `DiscreteDP` to SA-pair form
Parameters
sparse : bool, optional(default=True)
Should the `Q` matrix be stored as a sparse matrix?
If true the CSR format is used
Returns
ddp_sa : DiscreteDP
The correspnoding DiscreteDP instance in SA-pair form
Notes
If this instance is already in SA-pair form then it is returned
un-modified'

def to_sa_pair_form(self, sparse=True):

    if self._sa_pair:
        return self
    else:
        (s_ind, a_ind) = np.where((self.R > (- np.inf)))
        RL = self.R[(s_ind, a_ind)]
        if sparse:
            QL = sp.csr_matrix(self.Q[(s_ind, a_ind)])
        else:
            QL = self.Q[(s_ind, a_ind)]
        return DiscreteDP(RL, QL, self.beta, s_ind, a_ind)
