Skip to content

Commit a283d63

Browse files
[analytics] Include basic stats for lists of tuples and records
1 parent 5fdc3eb commit a283d63

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/orchard/inspect/analytics.clj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
(if (and (< i limit) (.hasNext it))
3939
(let [x (.next it)]
4040
(recur (inc i) (inc-if n (pred x))))
41-
[n (/ n i)]))))
41+
[n (if (pos? i) (/ n i) 0.0)]))))
4242

4343
(defn- bounded-count [limit coll]
4444
(first (count-pred (constantly true) limit coll)))
@@ -138,10 +138,14 @@
138138
(when (list-of-tuples? coll)
139139
(let [cnt (bounded-count *size-cutoff* coll)
140140
all (into [] (take *size-cutoff*) coll)
141-
longest (min 20 (apply max (map count all)))]
141+
longest (->> all
142+
(keep #(when (instance? List %) (bounded-count 20 %)))
143+
(apply max)
144+
(min 20))]
142145
(non-nil-hmap
143146
:cutoff? (when (>= cnt *size-cutoff*) true)
144147
:count cnt
148+
:types (*frequencies (map type coll))
145149
:tuples (mapv (fn [i]
146150
(basic-list-stats
147151
(mapv #(when (vector? %) (nth % i nil)) all)
@@ -155,6 +159,7 @@
155159
(non-nil-hmap
156160
:cutoff? (when (>= cnt *size-cutoff*) true)
157161
:count cnt
162+
:types (*frequencies (map type coll))
158163
:by-key (into {}
159164
(for [k ks]
160165
(let [kcoll (mapv #(get % k) coll)]

0 commit comments

Comments
 (0)