diff --git a/src/propeller/downsample.cljc b/src/propeller/downsample.cljc index 8037515..437ef3a 100644 --- a/src/propeller/downsample.cljc +++ b/src/propeller/downsample.cljc @@ -79,7 +79,7 @@ (utils/filter-by-index distance-list (map #(:index %) tournament))) (map #(:distances %) new-downsample))) selected-case-index (metrics/argmax min-case-distances)] - (if (or (<= (apply max min-case-distances) case-delta) (zero? (count cases-to-pick-from))) + (if (or (= 0 (count tournament)) (<= (apply max min-case-distances) case-delta)) new-downsample (do (if (sequential? (:input1 (first new-downsample))) diff --git a/src/propeller/tools/metrics.cljc b/src/propeller/tools/metrics.cljc index 2ead5ae..dfecf00 100755 --- a/src/propeller/tools/metrics.cljc +++ b/src/propeller/tools/metrics.cljc @@ -12,11 +12,13 @@ (defn argmax "returns the index of the maximum value in a list, randomly tiebreaking" [coll] - (->> coll - (map-indexed vector) - (filter #(= (apply max coll) (second %))) - rand-nth - first)) + (if (zero? (count coll)) + :null + (->> coll + (map-indexed vector) + (filter #(= (apply max coll) (second %))) + rand-nth + first))) (defn mean "Returns the mean of a collection."