Preparing for second go at release.
This commit is contained in:
parent
7e95669ee7
commit
c6e85b5500
9 changed files with 271 additions and 289 deletions
|
|
@ -8,205 +8,214 @@
|
|||
001 (ns sparse-array.extract
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
002 (:require [sparse-array.core :refer :all]))
|
||||
002 "Extracting interesting data from sparse arrays."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
003 (:require [sparse-array.core :refer [*safe-sparse-operations*
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 dense-array? dense-dimensions
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 make-sparse-array sparse-array?]]))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
003
|
||||
006
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
004 ;;; The whole point of working with sparse arrays is to work with interesting
|
||||
007 ;;; The whole point of working with sparse arrays is to work with interesting
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
005 ;;; subsets of arrays most of which are uninteresting. To extract an
|
||||
008 ;;; subsets of arrays most of which are uninteresting. To extract an
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
006 ;;; interesting subset from an array, we're going to need an extract function.
|
||||
009 ;;; interesting subset from an array, we're going to need an extract function.
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
007
|
||||
010
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
008 (defn- extract-from-sparse
|
||||
011 (defn- extract-from-sparse
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
009 "Return a subset of this sparse `array` comprising all those cells for which
|
||||
012 "Return a subset of this sparse `array` comprising all those cells for which
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
010 this `function` returns a 'truthy' value."
|
||||
013 this `function` returns a 'truthy' value."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
011 [array function]
|
||||
014 [array function]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
012 (reduce
|
||||
015 (reduce
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
013 merge
|
||||
016 merge
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
014 (apply
|
||||
017 (apply
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
015 make-sparse-array
|
||||
018 make-sparse-array
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
016 (cons
|
||||
019 (cons
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
017 (:coord array)
|
||||
020 (:coord array)
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
018 (if (coll? (:content array)) (:content array))))
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
021 (when (coll? (:content array)) (:content array))))
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
019 (map
|
||||
022 (map
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
020 #(if
|
||||
023 #(if
|
||||
</span><br/>
|
||||
<span class="covered" title="5 out of 5 forms covered">
|
||||
021 (= :data (:content array))
|
||||
024 (= :data (:content array))
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
022 (if (function (array %)) {% (array %)})
|
||||
<span class="covered" title="12 out of 12 forms covered">
|
||||
025 (when (function (array %)) {% (array %)})
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
023 (let [v (extract-from-sparse (array %) function)]
|
||||
026 (let [v (extract-from-sparse (array %) function)]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
024 (if
|
||||
027 (if
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
025 (empty?
|
||||
028 (empty?
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
026 (filter integer? (keys v)))
|
||||
029 (filter integer? (keys v)))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
027 nil
|
||||
030 nil
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
028 {% v})))
|
||||
031 {% v})))
|
||||
</span><br/>
|
||||
<span class="covered" title="6 out of 6 forms covered">
|
||||
029 (filter integer? (keys array)))))
|
||||
032 (filter integer? (keys array)))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
030
|
||||
033
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
031 (defn extract-from-dense
|
||||
034 (defn extract-from-dense
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
032 "Return a subset of this dense `array` comprising all those cells for which
|
||||
035 "Return a subset of this dense `array` comprising all those cells for which
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
033 this `function` returns a 'truthy' value. Use these `axes` if provided."
|
||||
036 this `function` returns a 'truthy' value. Use these `axes` if provided."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
034 ([array function]
|
||||
037 ([array function]
|
||||
</span><br/>
|
||||
<span class="covered" title="15 out of 15 forms covered">
|
||||
035 (extract-from-dense array function (map #(keyword (str "i" %)) (range))))
|
||||
038 (extract-from-dense array function (map #(keyword (str "i" %)) (range))))
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
036 ([array function axes]
|
||||
039 ([array function axes]
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
037 (let
|
||||
040 (let
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
038 [dimensions (dense-dimensions array)]
|
||||
041 [dimensions (dense-dimensions array)]
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
039 (reduce
|
||||
042 (reduce
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
040 merge
|
||||
043 merge
|
||||
</span><br/>
|
||||
<span class="covered" title="7 out of 7 forms covered">
|
||||
041 (apply make-sparse-array (take dimensions axes))
|
||||
044 (apply make-sparse-array (take dimensions axes))
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
042 (if
|
||||
045 (if
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
043 (= dimensions 1)
|
||||
046 (= dimensions 1)
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
044 (map
|
||||
047 (map
|
||||
</span><br/>
|
||||
<span class="covered" title="9 out of 9 forms covered">
|
||||
045 (fn [i v] (if (function v) (hash-map i v)))
|
||||
<span class="covered" title="10 out of 10 forms covered">
|
||||
048 (fn [i v] (when (function v) (hash-map i v)))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
046 (range)
|
||||
049 (range)
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
047 array)
|
||||
050 array)
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
048 (map
|
||||
051 (map
|
||||
</span><br/>
|
||||
<span class="covered" title="15 out of 15 forms covered">
|
||||
049 (fn [i v] (if (empty? (filter integer? (keys v))) nil (hash-map i v)))
|
||||
052 (fn [i v] (if (empty? (filter integer? (keys v))) nil (hash-map i v)))
|
||||
</span><br/>
|
||||
<span class="covered" title="2 out of 2 forms covered">
|
||||
050 (range)
|
||||
053 (range)
|
||||
</span><br/>
|
||||
<span class="covered" title="11 out of 11 forms covered">
|
||||
051 (map #(extract-from-dense % function (rest axes)) array)))))))
|
||||
054 (map #(extract-from-dense % function (rest axes)) array)))))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
052
|
||||
055
|
||||
</span><br/>
|
||||
<span class="covered" title="1 out of 1 forms covered">
|
||||
053 (defn extract
|
||||
056 (defn extract
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
054 "Return a sparse subset of this `array` - which may be either sparse or
|
||||
057 "Return a sparse subset of this `array` - which may be either sparse or
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
055 dense - comprising all those cells for which this `function` returns a
|
||||
058 dense - comprising all those cells for which this `function` returns a
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
056 'truthy' value."
|
||||
059 'truthy' value."
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
057 [array function]
|
||||
060 [array function]
|
||||
</span><br/>
|
||||
<span class="partial" title="2 out of 4 forms covered">
|
||||
058 (cond
|
||||
061 (cond
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
059 (sparse-array? array)
|
||||
062 (sparse-array? array)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
060 (extract-from-sparse array function)
|
||||
063 (extract-from-sparse array function)
|
||||
</span><br/>
|
||||
<span class="covered" title="3 out of 3 forms covered">
|
||||
061 (dense-array? array)
|
||||
064 (dense-array? array)
|
||||
</span><br/>
|
||||
<span class="covered" title="4 out of 4 forms covered">
|
||||
062 (extract-from-dense array function)
|
||||
065 (extract-from-dense array function)
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
063 *safe-sparse-operations*
|
||||
066 *safe-sparse-operations*
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 1 forms covered">
|
||||
064 (throw
|
||||
067 (throw
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
065 (ex-info
|
||||
068 (ex-info
|
||||
</span><br/>
|
||||
<span class="not-tracked" title="0 out of 0 forms covered">
|
||||
066 "Argument passed as `array` is neither sparse nor dense."
|
||||
069 "Argument passed as `array` is neither sparse nor dense."
|
||||
</span><br/>
|
||||
<span class="not-covered" title="0 out of 3 forms covered">
|
||||
067 {:array array}))))
|
||||
070 {:array array}))))
|
||||
</span><br/>
|
||||
<span class="blank" title="0 out of 0 forms covered">
|
||||
068
|
||||
071
|
||||
</span><br/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue