f5ba1df0169bf9f3e9e82d409c528d0642494665,src/gensim/similarities/docsim.py,MatrixSimilarity,getSimilarities,#MatrixSimilarity#Any#,127

Before Change


        or a numpy array, or a `scipy.sparse` matrix.
        
        if scipy.sparse.issparse(doc):
            vec = doc.toarray().flatten()
        elif isinstance(doc, numpy.ndarray):
            vec = doc
        else:
            vec = matutils.sparse2full(doc, self.numFeatures)
        vec = numpy.asfortranarray(vec, dtype=self.corpus.dtype).reshape(self.numFeatures, 1)

        // compute cosine similarity against every other document in the collection
        gemv = matutils.blas("gemv", self.corpus)
        allSims = gemv(1.0, self.corpus, vec) // N x T * T x 1 = N x 1
        allSims = list(allSims.flat) // convert to plain python list
        assert len(allSims) == self.corpus.shape[0] // make sure no document got lost!
        return allSims
//endclass MatrixSimilarity


After Change



        // do a little transposition dance to stop numpy from making a copy of
        // self.corpus internally in dot (very slow).
        return numpy.dot(self.corpus, query.T).T // XXX: removed casting the result to list; does anyone care?
//endclass MatrixSimilarity

Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 8

Instances


Project Name: RaRe-Technologies/gensim
Commit Name: f5ba1df0169bf9f3e9e82d409c528d0642494665
Time: 2011-05-15
Author: radimrehurek@seznam.cz
File Name: src/gensim/similarities/docsim.py
Class Name: MatrixSimilarity
Method Name: getSimilarities


Project Name: neurosynth/neurosynth
Commit Name: 73675264dd48387319f62780b52d81389016cc1f
Time: 2014-03-24
Author: tyarkoni@gmail.com
File Name: neurosynth/base/dataset.py
Class Name: FeatureTable
Method Name: get_ids


Project Name: neurosynth/neurosynth
Commit Name: 73675264dd48387319f62780b52d81389016cc1f
Time: 2014-03-24
Author: tyarkoni@gmail.com
File Name: neurosynth/base/dataset.py
Class Name: FeatureTable
Method Name: get_features_by_ids