# Buggy code
def get_similarities(self, query):
    """Get similarity between `query` and current index instance.

    Warnings
    --------
    Do not use this function directly; use the self[query] syntax instead.

    Parameters
    ----------
    query : {list of (int, number), iterable of list of (int, number), :class:`scipy.sparse.csr_matrix`
        Document or collection of documents.

    Return
    ------
    :class:`numpy.ndarray`
        Similarity matrix.

    """
    if isinstance(query, numpy.ndarray):
        # Convert document indexes to actual documents.
        query = [self.corpus[i] for i in query]

    if not query or not isinstance(query[0], list):
        query = [query]

    n_queries = len(query)
    result = []
    for qidx in range(n_queries):
        # Compute similarity for each query.
        qresult = [
            matutils.softcossim(document, query[qidx], self.similarity_matrix)
            for document in self.corpus
        ]
        qresult = numpy.array(qresult)

        # Append single query result to list of all results.
        result.append(qresult)

    if len(result) == 1:
        # Only one query.
        result = result[0]
    else:
        result = numpy.array(result)

    return result


# Traceback (RuntimeError)
In [249]: softcos_index[tfidf[corpus]]
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-249-2d8c4d759cc9> in <module>()
----> 1 softcos_index[tfidf[corpus]]

/Users/natalied/Projects/canonical_answers/.venv/lib/python2.7/site-packages/gensim/interfaces.pyc in __getitem__(self, query)
365                 else:
366                     query = matutils.unitvec(query)
--> 367         result = self.get_similarities(query)
368
369         if self.num_best is None:

/Users/natalied/Projects/canonical_answers/.venv/lib/python2.7/site-packages/gensim/similarities/docsim.pyc in get_similarities(self, query)
936             query = [self.corpus[i] for i in query]
937
--> 938         if not query or not isinstance(query[0], list):
939             query = [query]
940

/Users/natalied/Projects/canonical_answers/.venv/lib/python2.7/site-packages/gensim/interfaces.pyc in __getitem__(self, docno)
215             return self.obj[self.corpus[docno]]
216         else:
--> 217             raise RuntimeError('Type {} does not support slicing.'.format(type(self.corpus)))
218
219

RuntimeError: Type <class 'gensim.corpora.textcorpus.TextCorpus'> does not support slicing.

# Fixed code
def get_similarities(self, query):
    """Get similarity between `query` and current index instance.

    Warnings
    --------
    Do not use this function directly; use the self[query] syntax instead.

    Parameters
    ----------
    query : {list of (int, number), iterable of list of (int, number)
        Document or collection of documents.

    Return
    ------
    :class:`numpy.ndarray`
        Similarity matrix.

    """

    is_corpus, query = utils.is_corpus(query)
    if not is_corpus:
        if isinstance(query, numpy.ndarray):
            # Convert document indexes to actual documents.
            query = [self.corpus[i] for i in query]
        else:
            query = [query]

    result = []
    for query_document in query:
        # Compute similarity for each query.
        qresult = [
            matutils.softcossim(query_document, corpus_document, self.similarity_matrix)
            for corpus_document in self.corpus
        ]
        qresult = numpy.array(qresult)

        # Append single query result to list of all results.
        result.append(qresult)

    if is_corpus:
        result = numpy.array(result)
    else:
        result = result[0]

    return result