scalanlp/breeze

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

Open

#422 geöffnet am 23. Juli 2015

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Scala (690 Forks)batch import
good first issuehelp wanted

Repository-Metriken

Stars
 (3.453 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

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().

Contributor Guide