scalanlp/breeze

SparseArray/SparseVector.compact should be split into 2-3 functions

開放

#422 建立於 2015年7月23日

 (0 則留言) (0 個反應) (0 位負責人)Scala (690 個分叉)batch import
good first issuehelp wanted

倉庫指標

星標
 (3,453 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Currently, SparseArray/SparseVector.compact does two separate things which are usually not intended to be done together. It should be split into three functions:

1: Add a def filter(predicate: T => Boolean): Unit function that allows specifying a predicate which is then used to strip certain values from the array/vector without reallocation.

2: Add a function called def tailor(): Unit that cuts down the memory usage to whatever is required to hold the values.

3: For backwards compatibility, replace the function compact with a function that calls filter(x => x == zero.zero) and then tailor().

貢獻者指南