def _axis2indices(self, arg, axis):

        if isinstance(arg, IndexMatrix):
            if axis == 0:
                return self._axis2indices(arg.row2word, axis=axis)
            elif axis == 1:
                return self._axis2indices(arg.col2word, axis=axis)
            else:
                raise ValueError("Axis must be 0 or 1.")

        res = []
        if axis == 0:
            word2blank = self.word2row
        elif axis == 1:
            word2blank = self.word2col
        else:
            raise ValueError("Axis needs to be 0 or 1")

        if isinstance(arg, slice):
            res = list(range(len(word2blank))[arg])
        elif isinstance(arg, str):
            res = word2blank[arg]
        elif isinstance(arg, Integral):
            res = arg
        elif type(arg) in (list, np.ndarray):
            for i, content in enumerate(arg):
                if type(content) in (bool, np.bool_) and content:  # Convert boolean lists to indices
                    res.append(i)
                elif isinstance(content, str):
                    res.append(word2blank[content])
                elif isinstance(content, Integral) and not isinstance(content, bool):
                    res.append(content)
        else:
            raise TypeError("This type is not supported for indexing")

        if type(arg) in (list, np.ndarray) and len(res) == 1:
            return res[0]
        else:
            return res
Makes arg ready to perform slicing on a scipy matrix.
dataset/ETHPy150Open jimmycallin/pydsm/pydsm/indexmatrix.py/IndexMatrix._axis2indices