summarizer
summarizer copied to clipboard
Avoid redundant np.array(np.transpose(...)) – use .T instead
https://github.com/iamprem/summarizer/blob/373aedfee1526dfa6ebd5a4789371e9f3140c61b/lsa.py#L43
In the code:
idfvector = numpy.array(numpy.transpose(idfvector))
both np.transpose() and np.array() return a NumPy array, so wrapping the result of np.transpose() in np.array() is redundant and causes unnecessary memory copying.
Moreover, it's more efficient and idiomatic to use the .T shorthand for transposition:
idfvector = idfvector.T
This avoids redundant operations, improves readability, and performs better, especially in performance-sensitive code.