source mapping for Rhino

source mapping for Rhino

--- src/clj/cljs/repl/rhino.clj
+++ src/clj/cljs/repl/rhino.clj
@@ -172,6 +172,23 @@
     {:require-foreign true
      :output-dir ".cljs_rhino_repl"
      :wrap wrap-fn})
+  repl/IParseStacktrace
+  (-parse-stacktrace [this frames-str ret {output-dir :output-dir}]
+    (vec
+      (map
+        (fn [frame-str]
+          (let [[file-side line-fn-side] (string/split frame-str #":")
+                file (string/replace file-side #"\s+at\s+" "")
+                [line function] (string/split line-fn-side #"\s+")]
+            {:file (string/replace file (str output-dir File/separator) "")
+             :function (when function
+                         (-> function
+                           (string/replace "(" "")
+                           (string/replace ")" "")))
+             :line (when line
+                     (Integer/parseInt line))
+             :column 0}))
+        (string/split frames-str #"\n"))))
   repl/IJavaScriptEnv
   (-setup [this opts]
     (rhino-setup this opts))
@@ -194,6 +211,15 @@
        :scope (.initStandardObjects cx)})))

 (comment
+
+  (repl/-parse-stacktrace (repl-env)
+    "\tat .cljs_rhino_repl/goog/../cljs/core.js:4215 (seq)
+\tat .cljs_rhino_repl/goog/../cljs/core.js:4245 (first)
+\tat .cljs_rhino_repl/goog/../cljs/core.js:5295 (ffirst)
+\tat <cljs repl>:1
+\tat <cljs repl>:1"
+    nil
+    {:output-dir ".cljs_rhino_repl"})

   (require '[cljs.repl :as repl])
   (require '[cljs.repl.rhino :as rhino])


add missing destructure of :segs & :prev-seg

--- src/clj/cljs/source_map.clj
+++ src/clj/cljs/source_map.clj
@@ -124,7 +124,8 @@
         (loop [sources (seq m) prev-seg nil source-idx 0 segs []]
           (if sources
             (let [[source lines] (first sources)
-                  segs (encode-source lines segs prev-seg source-idx names->idx name-idx)]
+                  {:keys [segs prev-seg]}
+                  (encode-source lines segs prev-seg source-idx names->idx name-idx)]
               (recur (next sources) prev-seg (inc source-idx) segs))
             segs))]
     (with-out-str


Reduce calculation cost of pileup

Reduce calculation cost of pileup

--- src/cljam/pileup/pileup.clj
+++ src/cljam/pileup/pileup.clj
@@ -4,24 +4,26 @@
             [cljam.pileup.common :refer [window-width step center]]
             [cljam.bam.reader]))

-(defn- count-for-alignment
-  [^clojure.lang.PersistentHashMap aln
-   ^String rname
-   ^clojure.lang.LazySeq positions]
+(defn- update-pile
+  [aln rname pile positions]
   (if (= rname (:rname aln))
-    (let [^Long left (:pos aln)
-          ^Long right (sam-util/get-end aln)]
-      (map (fn [p]
-             (if (<= left p right) 1 0)) positions))
-    (repeat (count positions) 0)))
+    (let [win-beg (first positions)
+          win-end (last positions)
+          left (max (:pos aln) win-beg)
+          right (min (sam-util/get-end aln) win-end)]
+      (loop [i left, pile* pile]
+        (if (<= i right)
+          (recur (inc i) (update-in pile* [(- i win-beg)] inc))
+          pile*)))
+    (vec (repeat (count pile) 0))))

 (defn- count-for-positions
-  "Returns a histogram value of the specified position."
-  [^clojure.lang.LazySeq alns
-   ^String rname positions]
-  (if (pos? (count alns))
-    (apply map + (map #(count-for-alignment % rname positions) alns))
-    (repeat (count positions) 0)))
+  [alns rname positions]
+  (loop [[aln & rest] alns
+         pile (vec (repeat (count positions) 0))]
+    (if aln
+      (recur rest (update-pile aln rname pile positions))
+      pile)))

 (defn rpositions
   ([^Long start ^Long end]


Added a few ways to implement color (some commented out)

--- src/cljs/zetawar/views.cljs
+++ src/cljs/zetawar/views.cljs
@@ -308,6 +308,11 @@

 (defn faction-settings [{:as views-ctx :keys [conn dispatch translate]}]
   (with-let [faction (subs/faction-to-configure conn)
+             ;color (when @faction
+              ;       (-> @faction
+              ;           :faction/color
+              ;           name
+              ;           string/capitalize))
              selected-player-type (r/atom nil)
              hide-settings (fn [ev]
                              (when ev (.preventDefault ev))
@@ -324,7 +329,12 @@
                                  :on-hide hide-settings}
      [:> js/ReactBootstrap.Modal.Header {:close-button true}
       [:> js/ReactBootstrap.Modal.Title
-       (translate :configure-faction-title)]]
+       (str "Configure Faction: " ;color)]]
+            (when @faction
+              (-> @faction
+                  :faction/color
+                  name
+                  string/capitalize)))]]
      [:> js/ReactBootstrap.Modal.Body
       [:form
        [:div.form-group


reboot crawl on nil response

reboot crawl on nil response

--- src/clueweb_disqus/core.clj
+++ src/clueweb_disqus/core.clj
@@ -159,9 +159,13 @@

             next-pg-content (rate-limited-download next-pg-url)]
         (write-content start-epoch next-pg-content)
-        (when-not (stop-iteration? start-epoch (get next-pg-content "response"))
-          (recur start-epoch
-                 next-pg-content))))))
+        (cond (nil? (last (get next-pg-response "response")))
+              (threads-since (str (inc (Long/parseLong start-epoch)))) ; just don't bother and reboot the crawl
+
+              (not
+               (stop-iteration? start-epoch (get next-pg-content "response")))
+              (recur start-epoch
+                     next-pg-content))))))

 (defn threads-since
   [start-epoch]


~(defn generate-question-and-correct-set): provide binding target-lexical-filter (used to control target language generation

--- src/babel/reader.clj
+++ src/babel/reader.clj
@@ -111,6 +111,8 @@

 (def ^:dynamic source-grammar-subset :all)
 (def ^:dynamic target-grammar-subset nil)
+(def ^:dynamic target-lexical-filter (fn [lexeme] true))
+
 (defn generate-question-and-correct-set [target-spec
                                          source-language source-locale
                                          target-language target-locale]
@@ -137,7 +139,9 @@
          (binding [babel.generate/lexical-filter
                    (fn [lexeme]
                      (and (= false (u/get-in lexeme [target-root-keyword :exception] false))
-                          (= false (u/get-in lexeme [:exception] false))))
+                          (= false (u/get-in lexeme [:exception] false))
+                          (target-lexical-filter lexeme)))
+
                    babel.generate/truncate? true
                    babel.generate/grammar (or target-grammar-subset
                                               (and


rename columns in SELECT for clarity

rename columns in SELECT for clarity

--- src/babel/reader.clj
+++ src/babel/reader.clj
@@ -121,14 +121,14 @@
             ;; one (random) expression.
             ;; instead, we should use the target.surface as an input to a hash function; that is,
             ;; ORDER BY the value of the hash function on each row.
-            (let [results (db/exec-raw [(str "SELECT target.serialized::text AS target,target.surface
-                                        FROM expression AS target
-                                       WHERE target.active=true
-                                         AND target.language=?
-                                         AND target.structure IS NOT NULL
-                                         AND target.surface != ''
-                                         AND target.structure @> '" target-json-spec "'
-                                         AND target.active=true")
+            (let [results (db/exec-raw [(str "SELECT serialized,surface "
+                                             "  FROM expression "
+                                             " WHERE active=true "
+                                             "   AND language=? "
+                                             "   AND structure IS NOT NULL "
+                                             "   AND surface != '' "
+                                             "   AND structure @> '" target-json-spec "' "
+                                             "   AND active=true")
                                         [target-language]]
                                        :results)]
               (if (empty? results)
@@ -163,21 +163,22 @@
                   ;; set to true or false, while subjects in English, at present, lack this
                   ;; (though this key might be added to the English lexicon later at
                   ;;  some point).
-                  (let [result (deserialize (read-string (:target target-expression)))
+                  (let [target-structure (deserialize (read-string (:serialized target-expression)))
                         ;; TODO: allow queries that have refs - might be
                         ;; useful for modeling anaphora and binding.
-                        target-semantics (get-in result [:synsem :sem])
                         source-language-keyword (keyword source-language)
                         target-language-keyword (keyword target-language)
-                        semantic-correspondence
-                        (-> @((models source-language-keyword))
-                            :semantic-correspondence
-                            target-language-keyword)
-                        source-semantics (-> result
-                                             (get-in [:synsem :sem])
-                                             (dissoc-paths semantic-correspondence)
-                                             strip-refs)
-                        json-target-semantics (json/write-str (strip-refs (get-in result [:synsem :sem])))
+                        target-semantics (get-in target-structure [:synsem :sem])
+                        ;; Removes certain parts of the target-semantics that are not expressed
+                        ;; in the source-semantics:
+                        semantic-correspondence (-> @((models source-language-keyword))
+                                                    :semantic-correspondence
+                                                    target-language-keyword)
+                        source-semantics (-> target-semantics
+                                             (dissoc-paths semantic-correspondence))
+
+                        ;; transform semantics to JSON so that we can search the expression database table.
+                        json-target-semantics (json/write-str (strip-refs target-semantics))
                         json-source-semantics (json/write-str (strip-refs source-semantics))]
                     (log/debug (str "target expression:" (:surface target-structure)))
                     (log/debug (str "target semantics:" (strip-refs target-semantics)))
@@ -213,7 +214,7 @@
                                        " source.structure->'synsem'->'sem' @> '" json-source-semantics "'")
                               message (str "no source expression found for target semantics: "
                                            (get-in (strip-refs (deserialize
-                                                                (read-string (:target target-expression))))
+                                                                (read-string (:structure target-expression))))
                                                    [:synsem :sem])
                                            "; used source semantics:" source-semantics "; SQL:" sql)]
                           (log/error message)


replace single ctrl channel w/ bus, add :bus-size to executor opts, add notify to IGraphExecutor

--- src/thi/ng/fabric/async.cljc
+++ src/thi/ng/fabric/async.cljc
@@ -24,7 +24,7 @@
 (defprotocol IGraphExecutor
   (execute! [_])
   (stop! [_])
-  (control-channel [_]))
+  (notify [_ evt]))

 (defn simple-collect
   [collect-fn]
@@ -124,6 +124,7 @@
 (def default-context-opts
   {:collect-thresh 0
    :signal-thresh  0
+   :bus-size       16
    :timeout        100
    :max-ops        1e6})

@@ -151,7 +152,7 @@
                  (assoc  :curr-vertex v)))))
         :curr-vertex))
   (vertex-for-id
-    [_ id] (-> @state :vertices id))
+    [_ id] (get-in @state [:vertices id]))
   (vertices
     [_] (-> @state :vertices vals)))

@@ -161,7 +162,6 @@
 (defn eager-vertex-processor
   [{:keys [id state] :as vertex} ctx]
   (let [{:keys [collect-thresh signal-thresh]} @ctx
-        ctrl (control-channel ctx)
         in   (input-channel vertex)]
     (go-loop []
       (let [[src-id sig] (<! in)]
@@ -169,11 +169,11 @@
           (do (debug (format "%d receive from %d: %s" id src-id (pr-str sig)))
               (receive-signal vertex src-id sig)
               (when (should-collect? vertex collect-thresh)
-                (when (>! ctrl [:collect id])
-                  (collect! vertex)
-                  (when (should-signal? vertex signal-thresh)
-                    (>! ctrl [:signal id])
-                    (signal! vertex))))
+                (notify ctx [:collect id])
+                (collect! vertex)
+                (when (should-signal? vertex signal-thresh)
+                  (notify ctx [:signal id])
+                  (signal! vertex)))
               (recur))
           (debug (str id " stopped")))))
     vertex))
@@ -188,15 +188,15 @@
        (deliver p)))

 (defn stop-execution
-  [ctrl vertices]
-  (close! ctrl)
+  [bus vertices]
+  (run! close! bus)
   (run! close-input! vertices))

 (defn async-context
   [opts]
   (let [ctx       (merge default-context-opts opts)
-        ctx       (update ctx :channel #(or % (chan)))
-        ctrl      (:channel ctx)
+        bus       (vec (repeatedly (:bus-size ctx) chan))
+        ctx       (assoc ctx :bus bus)
         processor (:processor ctx)
         c-thresh  (:collect-thresh ctx)
         s-thresh  (:signal-thresh ctx)
@@ -209,10 +209,10 @@
       IGraphExecutor
       (stop!
         [_]
-        (stop-execution ctrl (vertices (:graph ctx)))
+        (stop-execution bus (vertices (:graph ctx)))
         result)
-      (control-channel
-        [_] ctrl)
+      (notify [_ evt]
+        (go (>! (rand-nth bus) evt)))
       (execute! [_]
         (if-not (realized? result)
           (let [t0 (System/nanoTime)]
@@ -228,7 +228,7 @@
               (loop [colls 0 sigs 0]
                 (if (<= (+ colls sigs) max-ops)
                   (let [t (timeout max-t)
-                        [[evt v ex] port] (alts! [ctrl t])]
+                        [[evt v ex] port] (alts! (conj bus t))]
                     (if (= port t)
                       (do (stop! _)
                           (execution-result :converged result colls sigs t0))
@@ -254,34 +254,34 @@
           (throw (IllegalStateException. "Context already executed once")))))))

 (defn dot
-     [path g flt]
-     (->> (vertices g)
-          (filter flt)
-          (mapcat
-           (fn [v]
-             (if-let [outs @(:outs v)]
-               (->> outs
-                    (map
-                     (fn [[k [_ opts]]]
-                       (str (:id v) "->" (:id k) "[label=" (pr-str opts) "];\n")))
-                    (cons
-                     (format
-                      "%d[label=\"%d (%s)\"];\n"
-                      (:id v) (:id v) (pr-str @v)))))))
-          (apply str)
-          (format "digraph g {
+  [path g flt]
+  (->> (vertices g)
+       (filter flt)
+       (mapcat
+        (fn [v]
+          (if-let [outs @(:outs v)]
+            (->> outs
+                 (map
+                  (fn [[k [_ opts]]]
+                    (str (:id v) "->" (:id k) "[label=" (pr-str opts) "];\n")))
+                 (cons
+                  (format
+                   "%d[label=\"%d (%s)\"];\n"
+                   (:id v) (:id v) (pr-str @v)))))))
+       (apply str)
+       (format "digraph g {
 node[color=black,style=filled,fontname=Inconsolata,fontcolor=white,fontsize=9];
 edge[fontname=Inconsolata,fontsize=9];
 ranksep=1;
 overlap=scale;
 %s}")
-          (spit path)))
+       (spit path)))

 (def g (compute-graph))
 (def ctx
   (async-context
    {:graph     g
-    :channel   (chan 1024)
+    :bus-size  64
     :processor eager-vertex-processor}))

 (defn signal-sssp
@@ -291,24 +291,6 @@
   (simple-collect
    (fn [val uncollected]
      (if val (reduce min val uncollected) (reduce min uncollected)))))
-
-(comment
-  (def a (add-vertex! g {::val 0   ::collect-fn collect-sssp}))
-  (def b (add-vertex! g {::val nil ::collect-fn collect-sssp}))
-  (def c (add-vertex! g {::val nil ::collect-fn collect-sssp}))
-  (def d (add-vertex! g {::val nil ::collect-fn collect-sssp}))
-
-  (connect-to! a b signal-sssp 1)
-  (connect-to! a c signal-sssp 3)
-  (connect-to! b c signal-sssp 1)
-  (connect-to! c d signal-sssp 1)
-
-  (prn @(execute! ctx))
-
-  (prn @a)
-  (prn @b)
-  (prn @c)
-  (prn @d))

 (defn make-strand
   [verts e-length]
@@ -338,12 +320,29 @@
     nil))

 (comment
+  (def a (add-vertex! g {::val 0   ::collect-fn collect-sssp}))
+  (def b (add-vertex! g {::val nil ::collect-fn collect-sssp}))
+  (def c (add-vertex! g {::val nil ::collect-fn collect-sssp}))
+  (def d (add-vertex! g {::val nil ::collect-fn collect-sssp}))
+
+  (connect-to! a b signal-sssp 1)
+  (connect-to! a c signal-sssp 3)
+  (connect-to! b c signal-sssp 1)
+  (connect-to! c d signal-sssp 1)
+
+  (prn @(execute! ctx))
+
+  (prn @a)
+  (prn @b)
+  (prn @c)
+  (prn @d))
+
+(comment
   (def g (compute-graph))
   (def ctx
     (async-context
      {:graph     g
-      :processor eager-vertex-processor
-      :channel   (chan 4096)}))
+      :processor eager-vertex-processor}))

   (def types
     '[animal vertebrae mammal human dog fish shark plant tree oak fir])
@@ -375,4 +374,3 @@
       (doseq [[a b] hierarchy]
         (connect-to! (verts a) (verts b) signal-forward nil))
       verts)))
-


Don't loop forever when search-sexp-boundary fails

I'd rather have a stacktrace somewhere than a runaway process keeping
one of my cores at 100% :(

--- src/refactor_nrepl/util.clj
+++ src/refactor_nrepl/util.clj
@@ -112,6 +112,9 @@
                  (close ch)
                  (recur chars (inc cnt) (dec op-cl) true)

+                 (> cnt (count s)) (throw (IllegalArgumentException.
+                                           "Can't find sexp boundary!"))
+
                  :else
                  (recur chars (inc cnt) op-cl ready))))
        0))))


Plaintext exporter

Plaintext exporter

--- src/zg/server.clj
+++ src/zg/server.clj
@@ -158,12 +158,23 @@
     [words]
     (json/write-str words))

+(defn words->text
+    [words]
+    (clojure.string/join "\n" words))
+
 (defn process-wordlist-json
     [request]
     (let [search-results (db-interface/read-all-words)
           json-output    (words->json search-results)]
         (-> (http-response/response json-output)
             (http-response/content-type "application/json"))))
+
+(defn process-wordlist-text
+    [request]
+    (let [search-results (db-interface/read-all-words)
+          text-output    (words->text search-results)]
+        (-> (http-response/response text-output)
+            (http-response/content-type "text/plain"))))

 ;defn process-delete-word
 ;   [request]
@@ -208,6 +219,7 @@
             "/users"             (process-user-list     request)
             "/user"              (process-user-info     request)
             "/wordlist/json"     (process-wordlist-json request)
+            "/wordlist/text"     (process-wordlist-text request)
             ;"/delete-word"      (process-delete-word   request)
             ;"/undelete-word"    (process-undelete-word request)
             )))


Simplify project manipulation state functions.

--- src/uxbox/state/project.cljs
+++ src/uxbox/state/project.cljs
@@ -11,9 +11,8 @@
 (defn dissoc-project
   "A reduce function for dissoc the project
   from the state map."
-  [state proj]
-  (let [uuid (:id proj)]
-    (update-in state [:projects-by-id] dissoc uuid)))
+  [state id]
+  (update-in state [:projects-by-id] dissoc id))

 (defn assoc-page
   "A reduce function for assoc the page
@@ -21,6 +20,23 @@
   [state page]
   (let [uuid (:id page)]
     (update-in state [:pages-by-id] assoc uuid page)))
+
+(defn dissoc-page-shapes
+  [state id]
+  (let [shapes (get-in state [:shapes-by-id])]
+    (assoc state :shapes-by-id (reduce-kv (fn [acc k v]
+                                            (if (= (:page v) id)
+                                              (dissoc acc k)
+                                              acc))
+                                          shapes
+                                          shapes))))
+
+(defn dissoc-page
+  "Remove page and all related stuff from the state."
+  [state id]
+  (-> state
+      (update :pages-by-id dissoc id)
+      (dissoc-page-shapes id)))

 (defn project-pages
   "Get a ordered list of pages that


[#3145] Don't reorder source merge columns

--- backend/src/akvo/lumen/lib/transformation/merge_datasets.clj
+++ backend/src/akvo/lumen/lib/transformation/merge_datasets.clj
@@ -168,7 +168,7 @@
                          conn
                          {:dataset-version-id (:id dataset-version)})
         dataset-csv-type? (csv-dataset? (db.dataset/dataset-import-type conn dataset-id))
-        columns-by-group (->> (set (get source "mergeColumns"))
+        columns-by-group (->> (get source "mergeColumns")
                               (map-indexed (fn [i column-name]
                                              (let [dg (engine/datagroup-by-column data-groups column-name)
                                                    column (first (filter #(= (get % "columnName") column-name) (:columns dg)))]


WIP: implementing imperative-style search algorithm using clj-iter.

--- src/clj/c2/ticks.clj
+++ src/clj/c2/ticks.clj
@@ -1,5 +1,6 @@
 (ns c2.ticks
-  (:use [c2.maths :only [sq]]))
+  (:use [c2.maths :only [sq ceil floor log10 expt]]
+        [iterate :only [iter]]))
 ;;Implementation of "An Extension of Wilkinson’s Algorithm for Positioning Tick Labels on Axes" by Justin Talbot, Sharon Lin, and Pat Hanrahan:
 ;;
 ;;    http://graphics.stanford.edu/vis/publications/2010/labeling-preprint.pdf
@@ -20,14 +21,14 @@

 (defn simplicity
   "Objective function modeling niceness of step sizes and whether a range includes zero."
-  [q Q j label-range-contains-zero]
+  [q j label-range-contains-zero]
   (let [v (if label-range-contains-zero 1 0)]
     (if (<= (count Q) 1)
       (+ (- 1 j) v)
       (+ (- 1 (/ (index-of q Q) (dec (count Q))) j)
          v))))

-(defn max-simplicity [q Q j] (simplicity q Q j true))
+(defn max-simplicity [q j] (simplicity q j true))

 (defn coverage
   "Objective function based on distances between extreme data and extreme labels"
@@ -45,12 +46,15 @@
                   (* 0.2 d-range))))
       1)))

+
 (defn density
   "Objective function for a candidate density r and desired density rt (e.g. labels-per-cm)"
   [r rt]
   ;;Note the formula should be 2-, not 1- as in the paper.
   (- 2 (max (/ r rt) (/ rt r))))

+;;Since the arguments are the same, I don't see what the story is with density / max density.
+;;This isn't satisfactorily explained in the paper.
 (defn max-density [r rt]
   (if (>= r rt)
     (- 2 (/ r rt))
@@ -60,14 +64,70 @@
   "Balance the relative merits of different metrics"
   [[simplicity coverage density legibility]]
   (let [w [0.2 0.25 0.5 0.05]]
-    (+ (* simplicity (w 1))
-       (* coverage (w 2))
-       (* density (w 3))
-       (* legibility (w 4)))))
+    (+ (* simplicity (w 0))
+       (* coverage (w 1))
+       (* density (w 2))
+       (* legibility (w 3)))))

 (defn search
-  "Find best ticks for the data range (dmin, dmax) and target label density m"
-  [dmin dmax m]
+  "Find best ticks for the data range (d-min, d-max) and target label density "
+  [d-min d-max & {:keys [target-density
+                         length]
+                  :or {target-density 0.01 ;;Default to one label per 100 px
+                       length         500}}]
+
+  ;;To be on the safe side, I've copied the imperative algorithm from the paper.
+  ;;If you rewrite it in an understandable and performant functional style, we'll accept a pull request and buy you a bottle of whiskey
+  (let [best-score (atom -2)
+        label (atom {})]
+
+    (iter {for q in Q}
+
+          (iter {for j from 1}
+                {for ms = (max-simplicity q j)}
+                {return-if (< (w [ms 1 1 1]) @best-score)}
+
+                (iter {for k from 2}
+                      {for md = (max-density (/ k length) target-density)}
+                      {return-if (< (w [ms 1 md 1]) @best-score)}
+
+                      (let [delta ;;power of ten by which to multiply the step size
+                            (/ (- d-max d-min)
+                               (* (inc k) j k))]
+                        (iter {for z from (ceil (log10 delta))}
+                              {for l-step = (* q j (expt 10 z))}
+                              {for mc = (max-coverage d-min d-max (* (dec k) l-step))}
+                              {return-if (< (w [ms mc md 1]) @best-score)}
+
+                              (iter {for start
+                                     from (- (floor (/ d-max l-step))
+                                             (dec k))
+                                     to (/ d-min l-step)
+                                     by (/ 1 j)}
+                                    {for l-min = (* start l-step)}
+                                    {for l-max = (+ l-min (* (dec k) l-step))}
+                                    {for s = (simplicity q j (label-range-contains-zero? l-min l-max l-step))}
+                                    {for c = (coverage d-min d-max l-min l-max)}
+                                    {for d = (density (/ k length) target-density)}
+                                    {for score = (w [s c d 1])}
+                                    {return-if (< score @best-score)}
+
+                                    ;;todo, optimize legibility
+                                    (reset! best-score score)
+                                    (reset! label {:l-min l-min
+                                                   :l-max l-max
+                                                   :l-step l-step})))))))
+
+    @label))
+
+(search 0.1 9)
+
+(comment
+  (iter {for j from 1 to 5}
+        {for y = (inc x)}
+        {for x = (inc j)}
+
+        (println y))
   )


[Add] fun +-exp

[Add] fun +-exp

--- src/clj_elm/core.clj
+++ src/clj_elm/core.clj
@@ -176,6 +176,15 @@
          "Recall: " (:Recall exp "\n")
          "Precision: " (:Precision exp) "\n\n"))

+(defn +-exp [exp1 exp2]
+  {:pre [(map? exp1) (map? exp2)]}
+  {:length-train-negative (+ (:length-train-negative exp1) (:length-train-negative exp2))
+   :length-test-negative (+ (:length-test-negative exp1) (:length-test-negative exp2))
+   :length-train-positive (+ (:length-train-positive exp1) (:length-train-positive exp2))
+   :length-test-positive (+ (:length-test-positive exp1) (:length-test-positive exp2))
+   :TP (+ (:TP exp1) (:TP exp2)) :FP (+ (:FP exp1) (:FP exp2))
+   :TN (+ (:TN exp1) (:TN exp2)) :FN (+ (:FN exp1) (:FN exp2))})
+
 (defn cross-validate
   ([dataset L k]
    {:pre [(instance? DataSet dataset) (integer? k) (integer? L)]}


Add a type hint.

Add a type hint.

--- src/cljam/io/vcf.clj
+++ src/cljam/io/vcf.clj
@@ -65,7 +65,7 @@
     (BCFReader. (.url rdr) (.meta-info rdr) (.header rdr)
                 input-stream (.start-pos rdr) (.index-delay rdr))))

-(defn clone-reader
+(defn ^Closeable clone-reader
   "Clones vcf/bcf reader sharing persistent objects."
   [rdr]
   (cond


Add `classed!` dom helper.

Add `classed!` dom helper.

--- src/cljs/c2/dom.cljs
+++ src/cljs/c2/dom.cljs
@@ -4,6 +4,7 @@
                [iterate :only [iter]])
   (:require [clojure.string :as string]
             [goog.dom :as gdom]
+            [goog.dom.classes :as gclasses]
             [goog.style :as gstyle]))

 ;; From Weavejester's Hiccup.
@@ -93,6 +94,11 @@
 (defn text [el v]
   (gdom/setTextContent el v))

+(defn classed!
+  "Adds or removes `class` to `el` based on boolean `classed?`."
+  [el class classed?]
+  (gclasses/enable (select el) class classed?))
+
 (def request-animation-frame
   (or (.-requestAnimationFrame js/window)
       (.-webkitRequestAnimationFrame js/window)


Fix exception caused by not specifying :tag-enrichment in argmap; lein release patch

--- src/clojush/args.clj
+++ src/clojush/args.clj
@@ -597,7 +597,7 @@
                                       (:atom-generators @push-argmap))))
     (swap! push-argmap assoc
            :replace-child-that-exceeds-size-limit-with :empty))
-  (when (> (:tag-enrichment argmap) 0)
+  (when (> (:tag-enrichment @push-argmap) 0)
     (swap! push-argmap assoc
            :atom-generators
            (let [tag-instructions [(tag-instruction-erc
@@ -614,7 +614,7 @@
                                    'integer_tag_char_instruction
                                    'integer_tag_string_instruction]]
              (into (:atom-generators @push-argmap)
-                   (take (* (:tag-enrichment argmap) (count tag-instructions))
+                   (take (* (:tag-enrichment @push-argmap) (count tag-instructions))
                          (cycle tag-instructions)))))))

 (defn reset-globals
@@ -630,3 +630,4 @@
    (load-push-argmap argmap)
    (reset-globals)))

+


Add :gene-oriented-non-recombinative and :uniform-non-recombinative options for :autoconstructive-genome-instructions

--- src/clojush/args.clj
+++ src/clojush/args.clj
@@ -666,7 +666,119 @@
                                                 ;genome_uniform_combination_and_deletion
                                                 ;genome_alternation
                                                 ;genome_uniform_crossover
-                                                )))]
+                                                ))
+                    :gene-oriented-non-recombinative
+                    (into (registered-for-stacks
+                            (if (:autoconstructive-environments @push-argmap)
+                              [:integer :boolean :exec :float :tag :environment]
+                              [:integer :boolean :exec :float :tag]))
+                          '(genome_pop
+                             genome_dup
+                             genome_swap
+                             genome_rot
+                             genome_flush
+                             genome_eq
+                             genome_stackdepth
+                             genome_yank
+                             genome_yankdup
+                             genome_shove
+                             genome_empty
+                             genome_gene_dup
+                             genome_gene_randomize
+                             genome_gene_replace
+                             genome_gene_delete
+                             genome_rotate
+                             ;genome_gene_copy
+                             ;genome_gene_copy_range
+                             genome_toggle_silent
+                             genome_silence
+                             genome_unsilence
+                             genome_instruction_eq
+                             genome_gene_close
+                             genome_gene_silent
+                             genome_close_inc
+                             genome_close_dec
+                             genome_new
+                             genome_parent1
+                             genome_parent2
+                             autoconstructive_integer_rand
+                             autoconstructive_boolean_rand
+                             genome_autoconstructing
+                             genome_if_autoconstructing
+                             genome_gene_genome_instruction
+                             genome_if_gene_genome_instruction
+                             genome_genesis
+                             ;;genome_uniform_instruction_mutation
+                             ;;genome_uniform_integer_mutation
+                             ;;genome_uniform_float_mutation
+                             ;;genome_uniform_tag_mutation
+                             ;;genome_uniform_string_mutation
+                             ;;genome_uniform_boolean_mutation
+                             ;;genome_uniform_close_mutation
+                             ;;genome_uniform_silence_mutation
+                             ;;genome_uniform_deletion
+                             ;;genome_uniform_addition
+                             ;;genome_uniform_addition_and_deletion
+                             ;genome_uniform_combination_and_deletion
+                             ;genome_alternation
+                             ;genome_uniform_crossover
+                             ))
+                    :uniform-non-recombinative
+                    (into (registered-for-stacks
+                            (if (:autoconstructive-environments @push-argmap)
+                              [:integer :boolean :exec :float :tag :environment]
+                              [:integer :boolean :exec :float :tag]))
+                          '(genome_pop
+                             genome_dup
+                             genome_swap
+                             genome_rot
+                             genome_flush
+                             genome_eq
+                             genome_stackdepth
+                             genome_yank
+                             genome_yankdup
+                             genome_shove
+                             genome_empty
+                             ;;genome_gene_dup
+                             ;;genome_gene_randomize
+                             ;;genome_gene_replace
+                             ;;genome_gene_delete
+                             ;;genome_rotate
+                             ;genome_gene_copy
+                             ;genome_gene_copy_range
+                             ;;genome_toggle_silent
+                             ;;genome_silence
+                             ;;genome_unsilence
+                             ;;genome_instruction_eq
+                             ;;genome_gene_close
+                             ;;genome_gene_silent
+                             ;;genome_close_inc
+                             ;;genome_close_dec
+                             genome_new
+                             genome_parent1
+                             genome_parent2
+                             autoconstructive_integer_rand
+                             autoconstructive_boolean_rand
+                             genome_autoconstructing
+                             genome_if_autoconstructing
+                             genome_gene_genome_instruction
+                             genome_if_gene_genome_instruction
+                             genome_genesis
+                             genome_uniform_instruction_mutation
+                             genome_uniform_integer_mutation
+                             genome_uniform_float_mutation
+                             genome_uniform_tag_mutation
+                             genome_uniform_string_mutation
+                             genome_uniform_boolean_mutation
+                             genome_uniform_close_mutation
+                             genome_uniform_silence_mutation
+                             genome_uniform_deletion
+                             genome_uniform_addition
+                             genome_uniform_addition_and_deletion
+                             ;genome_uniform_combination_and_deletion
+                             ;genome_alternation
+                             ;genome_uniform_crossover
+                             )))]
       (when (not (some #{instr} (:atom-generators @push-argmap)))
         (swap! push-argmap assoc :atom-generators (conj (:atom-generators @push-argmap) instr))))
     (swap! push-argmap assoc


Completed previous commit (util.clj hadn't been saved).

--- src/clojush/util.clj
+++ src/clojush/util.clj
@@ -105,7 +105,8 @@
    counts as a point."
   [tree]
   (if (seq? tree)
-    (inc (apply + (map count-points tree)))
+    (+ (count (flatten tree))
+       (count-parens tree))
     1))

 (defn code-at-point


Refactor resolve

Refactor resolve

--- test-cljs/frontend/test_send.cljs
+++ test-cljs/frontend/test_send.cljs
@@ -298,48 +298,55 @@

-
-
-
-
-
-(defn resolve [query]
+(defn resolve* [mapping key children]
+  (async/map (fn [& vals]
+               {key (into {}
+                          (map #(vector (:key %1) %2)
+                               children vals))})
+             (map #(async/map (:key %) [((get mapping (:key %)) %)])
+                  children)))
+
+
+(defn resolve [root-mapping query]
   (let [ast (om/query->ast query)]
-    (async/map (fn [user]
-                 {:root/user user})
-               [(async/map :root/user
-                           [(async/map (fn [name color number fellow-user]
-                                         {:root/user {:user/name name
-                                                      :user/favorite-color color
-                                                      :user/favorite-number number
-                                                      :user/favorite-fellow-user fellow-user}})
-                                       (let [name-c
-                                             (doto (async/promise-chan)
-                                               (put! {:user/name "nipponfarm"}))
-                                             color-and-number-chan
-                                             (doto (async/promise-chan)
-                                               (put! {:user/favorite-color :color/blue
-                                                      :user/favorite-number 42}))
-                                             fellow-user-chan
-                                             (doto (async/promise-chan)
-                                               (put! {:user/favorite-fellow-user {:user/name "jburnford"
-                                                                                :user/favorite-color :color/red
-                                                                                :user/favorite-number 7}}))]
-                                         [(async/map :user/name [name-c])
-                                          (async/map :user/favorite-color [color-and-number-chan])
-                                          (async/map :user/favorite-number [color-and-number-chan])
-                                          (async/map :user/favorite-fellow-user [fellow-user-chan])]))])])))
+    (async/map ::root [(resolve* root-mapping ::root (:children ast))])))
+
+(def User
+  {:user/name
+   #(doto (async/promise-chan)
+      (put! {:user/name "nipponfarm"}))
+
+   :user/favorite-color
+   #(doto (async/promise-chan)
+      (put! {:user/favorite-color :color/blue
+             :user/favorite-number 42}))
+
+   :user/favorite-number
+   #(doto (async/promise-chan)
+      (put! {:user/favorite-color :color/blue
+             :user/favorite-number 42}))
+
+   :user/favorite-fellow-user
+   #(doto (async/promise-chan)
+      (put! {:user/favorite-fellow-user {:user/name "jburnford"
+                                         :user/favorite-color :color/red
+                                         :user/favorite-number 7}}))})
+
+
+(def Root
+  {:root/user
+   #(resolve* User :root/user (:children %))})

 (deftest new-thing-works
   (async done
     (go
-      (let [c (resolve '[{(:root/user {:user/name "nipponfarm"})
-                            [:user/name
-                             :user/favorite-number
-                             :user/favorite-color
-                             {:user/favorite-fellow-user [:user/favorite-color
-                                                          :user/favorite-color]}]}])]
+      (let [c (resolve Root '[{(:root/user {:user/name "nipponfarm"})
+                               [:user/name
+                                :user/favorite-color
+                                :user/favorite-number
+                                {:user/favorite-fellow-user [:user/favorite-color
+                                                             :user/favorite-color]}]}])]
         ;; Keeps delivering the same data.
         (is (= (repeat 2 {:root/user {:user/name "nipponfarm"
                                       :user/favorite-color :color/blue


Fix bugzilla-id parser

Fix bugzilla-id parser

--- src/atom_finder/questions/bug_densities.clj
+++ src/atom_finder/questions/bug_densities.clj
@@ -17,9 +17,9 @@
        ;(#(string/join (.getShortMessage %1) (.getFullMessage %1)))
        .getFullMessage
        ;(prn)
-       (re-seq #"(?:PR|pr).*?(?:(\S+)/)?(\d{5,})")
+       (re-seq #"(?:PR|pr).*?(?:(\S+)/)?(\d{5,9})")
        (#(for [[match branch id] %]
-          {:branch branch :bug-id (Integer/parseInt id)}))
+          {:branch branch :bug-id (Long/parseLong id)}))
        (group-by :bug-id)
        (map-values #(apply max-key (comp count :branch) %))
        vals


property based testing on undo

property based testing on undo


a little more whitespace changes

a little more whitespace changes

--- src/smallblog/templates.clj
+++ src/smallblog/templates.clj
@@ -1,10 +1,10 @@
 (ns smallblog.templates
     (:use			[ring.util.codec :only (url-encode)]
-        [clojure.string :only (join)])
+          [clojure.string :only (join)])
     (:require		[net.cgrand.enlive-html :as html]
-        [clj-time.core :as clj-time]
-        [clj-time.format :as clj-time-format]
-        [clj-time.coerce :as clj-time-coerce])
+              [clj-time.core :as clj-time]
+              [clj-time.format :as clj-time-format]
+              [clj-time.coerce :as clj-time-coerce])
     (:import		[org.mozilla.javascript Context ScriptableObject]))

 (def *https-port* 4330)


Close result-chan after putting complete maze.

--- src/snergly/algorithms.cljc
+++ src/snergly/algorithms.cljc
@@ -52,7 +52,8 @@
                               (go (async/>! result-chan g)))
                             (binary-tree-step (g/begin-step g) c))
           grid (assoc grid :algorithm-name "binary-tree")]
-      (async/>! result-chan (reduce step-and-report grid (g/grid-coords grid))))))
+      (async/>! result-chan (reduce step-and-report grid (g/grid-coords grid)))
+      (async/close! result-chan))))

 (defn sidewinder-end-run? [cell]
   (let [on-east-side? (not (:east cell))
@@ -84,7 +85,9 @@
              (async/>! result-chan grid))
     (let [[new-grid processed-run] (sidewinder-step (g/begin-step grid) coord current-run)]
       (if (empty? coords)
-        (async/>! result-chan new-grid)
+        (do
+          (async/>! result-chan new-grid)
+          (async/close! result-chan))
         (recur new-grid
                coords
                (conj processed-run (first coords)))))))
@@ -156,7 +159,9 @@
                  ;; perhaps by annotating the path cells with a color.
                  [new-grid new-unvisited] (wilsons-carve-passage grid path unvisited result-chan report-partial-steps?)]
              (if (empty? new-unvisited)
-               (async/>! result-chan new-grid)
+               (do
+                 (async/>! result-chan new-grid)
+                 (async/close! result-chan))
                (recur new-grid
                       new-unvisited
                       (rand-nth new-unvisited))))))
@@ -189,7 +194,10 @@
         (async/>! result-chan grid)))
     (let [[new-grid next-coord] (hunt-and-kill-step (g/begin-step grid) current-coord)]
       (if-not next-coord
-        (async/>! result-chan new-grid)
+        (do
+          (async/>! result-chan new-grid)
+          (async/close! result-chan)
+          )
         (recur new-grid next-coord)))))

 (s/defn maze-recursive-backtrack :- g/Grid [grid :- g/Grid result-chan report-partial-steps?]


brezenhame works with 2nd quadrant

brezenhame works with 2nd quadrant

--- src/labs_4_cource/primitives.cljs
+++ src/labs_4_cource/primitives.cljs
@@ -15,27 +15,33 @@
               [x2 y2] p2
               length (max (Math/abs (- x2 x1)) (Math/abs (- y2 y1)))
               dx (/ (- x2 x1) length)
-              dy (/ (- y2 y1) length)]
+              dy (/ (- y2 y1) length)
+              ]
             (->> [x1 y1 0]
                  (iterate (fn [[x y i]] [(+ x dx) (+ y dy) (+ i 1)]))
                  (take-while (fn [[x y i]] (<= i length)))
                  (map (fn [[x y]] [ (floor x) (floor y)]))))))
+
+(defn calc-steps [coordinate]
+    (mapv Math/sign coordinate)  )

 (deftype BrezenhameLine [p1 p2]
     Line
     (line-points [this]
         (let [[x1 y1] p1
               [x2 y2] p2
-              dx (- x2 x1)
-              dy (- y2 y1)
-              e (- (* 2 dy) dx)]
+              dx  (- x2 x1)
+              dy  (- y2 y1)
+              e (- (* 2 dy) (Math/abs dx))
+              [x-step y-step] (calc-steps [dx dy])
+              ]
             (->>  [x1 y1 e]
                   (iterate (fn [[x y e]]
-                               (if (>= e 0) [(+ 1 x) (+ 1 y) (+ e (* 2 dy) (- (* 2 dx)))]
-                                   [(+ 1 x) y (+ e (* 2 dy))])))
-                  (take dx)
+                               (if (>= e 0) [(+ x-step x) (+ y-step y) (+ e (* 2 dy) (- (* 2 (Math/abs dx))))]
+                                   [(+ x-step x) y (+ e (* 2 dy))])))
+                  (take (+ 1 (Math/abs dx)))
                   (map (fn [[x y]] [x y]))
-                 ))))
+                  ))))

 (deftest line-from-book
     (are [src expected] (= src expected)
@@ -48,3 +54,10 @@
         (line-points (BrezenhameLine. [0 0] [9 4])) [[0 0] [1 0] [2 1] [3 1] [4 2] [5 2] [6 3] [7 3] [8 4] [9 4]]
         (line-points (BrezenhameLine.  [5 0] [0 1])) [[5 0] [4 0] [3 0] [2 1] [1 1] [0 1]]))
 (cljs.test/run-tests)
+
+(deftest steps
+    (are [src expected] (= (calc-steps src) expected)
+        [1 1] [1 1]
+        [1 -1] [1 -1]
+        [-1 1] [-1 1]
+        [-1 -1] [-1 -1]))


Migrate to new query builder

Migrate to new query builder

--- src/clojure/clojurewerkz/cassaforte/cql.clj
+++ src/clojure/clojurewerkz/cassaforte/cql.clj
@@ -142,8 +142,9 @@
   [^Session session & query-params]

   (cc/execute session
-              ;; (apply new-query-api/insert query-params)
-              (compile-query- q/insert-query query-params)))
+              (apply new-query-api/insert query-params)
+              ;; (compile-query- q/insert-query query-params)
+              ))

 (defn insert-async
   "Same as insert but returns a future"


Moved part of conversion to cql generation.

--- src/clojure/clojurewerkz/cassaforte/cql.clj
+++ src/clojure/clojurewerkz/cassaforte/cql.clj
@@ -18,34 +18,6 @@

 (def ^{:cons true :doc "Default compression level that is used for CQL queries"}
   default-compression (Compression/NONE))
-
-(defprotocol CQLValue
-  (to-cql-value [value] "Converts the given value to a CQL string representation"))
-
-(extend-protocol CQLValue
-  nil
-  (to-cql-value [value]
-    "null")
-
-  Integer
-  (to-cql-value [^Integer value]
-    (str value))
-
-  Long
-  (to-cql-value [^Long value]
-    (str value))
-
-  clojure.lang.BigInt
-  (to-cql-value [^clojure.lang.BigInt value]
-    (str value))
-
-  clojure.lang.Named
-  (to-cql-value [^clojure.lang.Named value]
-    (name value))
-
-  String
-  (to-cql-value [^String value]
-    (escape value)))

 (defn quote-identifier
   "Quotes the provided identifier"


SQS/SNS Hackfest - Added env utility functions.

--- common-lib/src/cmr/common/util.clj
+++ common-lib/src/cmr/common/util.clj
@@ -5,10 +5,10 @@
    [cheshire.core :as json]
    [clojure.data.codec.base64 :as b64]
    [clojure.java.io :as io]
-   [clojure.pprint :refer [print-table]]
+   [clojure.pprint :refer [pprint print-table]]
    [clojure.reflect :refer [reflect]]
    [clojure.set :as set]
-   [clojure.string :as str]
+   [clojure.string :as string]
    [clojure.template :as template]
    [clojure.test :as test]
    [clojure.walk :as w]
@@ -115,12 +115,12 @@
 (defn safe-lowercase
   "Returns the given string in lower case safely."
   [v]
-  (when v (str/lower-case v)))
+  (when v (string/lower-case v)))

 (defn safe-uppercase
   "Returns the given string in upper case safely."
   [v]
-  (when v (str/upper-case v)))
+  (when v (string/upper-case v)))

 (defn match-enum-case
   "Given a string and a collection of valid enum values, return the proper-cased
@@ -823,7 +823,7 @@
   digit and non-digit subsequences. Digits are returned as integers and the
   vector is guaranteed to start with a (potentially empty) string."
   [s]
-  (let [lower-s (str/lower-case s)
+  (let [lower-s (string/lower-case s)
         result (map #(if (re-matches #"\d+" %)
                        (Integer/parseInt % 10)
                        %)
@@ -899,3 +899,36 @@
       (filter (fn [x]
                 (contains? (:flags x) :public))
               (:members (reflect obj))))))
+
+(defn show-env
+  "Show the system environment currently available to Clojure.
+
+  Example usage:
+  ```
+  (show-env)
+  (show-env keyword)
+  (show-env (comp keyword string/lower-case))
+  ```"
+  ([]
+   (show-env identity))
+  ([key-fn]
+   (show-env key-fn (constantly true)))
+  ([key-fn filter-fn]
+   (show-env key-fn filter-fn (System/getenv)))
+  ([key-fn filter-fn data]
+   (->> data
+        (filter filter-fn)
+        (map (fn [[k v]] [(key-fn k) v]))
+        (into (sorted-map))
+        (pprint))
+   :ok))
+
+(defn show-cmr-env
+  "Show just the system environment variables with the `CMR_` prefix."
+  []
+  (show-env
+    (comp keyword
+          string/lower-case
+          #(string/replace % "_" "-")
+          #(string/replace % #"^CMR_" ""))
+    #(string/starts-with? %1 "CMR_")))


docstring

docstring

--- src/desdemona/ui/table.cljs
+++ src/desdemona/ui/table.cljs
@@ -10,6 +10,8 @@
    (conj coll k)))

 (defn columns-toggler-component
+  "Component with a list of buttons with a click handler to toggle keys in
+  given session-entry."
   [ks session-entry]
   (into [:ul.nav.nav-pills.nav-stacked]
    (for [k ks]


forgot to save

forgot to save

--- src/cortex/tree.cljc
+++ src/cortex/tree.cljc
@@ -216,8 +216,8 @@
   (mode (map #(tree-classify % sample) forest)))

 (defn forest-classify-dataset
-  [forest data]
-  (apply merge-with + (map #(tree-classify-dataset % data) forest)))
+  [forest data labels]
+  (apply merge-with + (map #(tree-classify-dataset % data labels) forest)))

 ;(defn predict
 ;  "Predict the regression target Y given a model and X by averaging


Kill a todo comment

Kill a todo comment

--- src/doctopus/storage/impls/permanent_fs.clj
+++ src/doctopus/storage/impls/permanent_fs.clj
@@ -5,8 +5,6 @@
              [files :as files]]
             [doctopus.storage.impls.fs-impl :refer [save-html-file] :as fs-impl]
             [me.raynes.fs :as fs]))
-
-;; TODO: this does not actually work the way we need it to! Neat! --RMD

 (def root (fs/file (:permanent-fs-root (server-config))))
 (if-not (fs/exists? root) (fs/mkdirs root))


Fixed navigate.cljs warnings

Fixed navigate.cljs warnings

--- src/lt/objs/sidebar/navigate.cljs
+++ src/lt/objs/sidebar/navigate.cljs
@@ -40,6 +40,8 @@
                                      final (.concat all-files other-files)]
                                  (js/_send obj-id :workspace-files final)
                                  ))))
+
+(declare sidebar-navigate)

 (behavior ::workspace-files
                   :triggers #{:workspace-files}


improved doc-strings for n-of and *-of checkers

--- src/midje/checkers/collection.clj
+++ src/midje/checkers/collection.clj
@@ -169,7 +169,8 @@
                   actual))))

 (defchecker n-of
-  "Can check if a sequence contains precisely n results, that all match the checker.
+  "Checks whether a sequence contains precisely n results, and
+   that they each match the checker.

   Ex. (fact (repeat 100 :a) => (n-of :a 100))"
   [expected expected-count]
@@ -180,10 +181,10 @@
 (defmacro #^:private generate-n-of-checkers []
   (macro-for [[num num-word] [[1 "one"] [2 "two"] [3 "three"] [4 "four"] [5 "five"]
                               [6 "six"] [7 "seven"] [8 "eight"] [9 "nine"] [10 "ten"]]]
-    (let [name (symbol (str num-word "-of"))
-          docstring (str "Can check if a sequence contains precisely n results, that all match the checker.
+    (let [name (symbol (str num-word "-of"))
+          docstring (cl-format nil "Checks whether a sequence contains precisely ~R result~:[s, and \n  that they each match~;, and \n  that it matches~] the checker.

-   Ex. (fact " (vec (repeat num :a )) " => (" name " :a))")]
+   Ex. (fact ~A => (~C :a))" num (= num 1) (vec (repeat num :a )) name)]
       `(defchecker ~name ~docstring [expected-checker#]
          (n-of expected-checker# ~num)))))


Don't show warning if we're still loading repos

--- src-cljs/frontend/components/add_projects.cljs
+++ src-cljs/frontend/components/add_projects.cljs
@@ -42,6 +42,9 @@
   (case vcs-type
     "bitbucket" (vcs-bitbucket? item)
     "github"    (vcs-github?    item)))
+
+(defn loading-repos-for-vcs-type? [user vcs-type]
+  (get-in user [:repos-loading vcs-type]))

 ;; This is only the keys that we're interested in in this namespace. We'd give
 ;; this a broader scope if we could, but that's the trouble with legacy keys:
@@ -266,7 +269,7 @@
     om/IRenderState
     (render-state [_ {:keys [selected-tab-name]}]
       (let [selected-org-login (:login selected-org)
-            loading-repos? (get-in user [:repos-loading (keyword (:vcs_type selected-org))])
+            loading-repos? (loading-repos-for-vcs-type? user (:vcs_type selected-org))
             repo-filter-string (get-in settings [:add-projects :repo-filter-string])
             show-forks (true? (get-in settings [:add-projects :show-forks]))]
         (html
@@ -480,7 +483,9 @@
      [:div#add-projects
       (when (seq (user-model/missing-scopes user))
         (missing-scopes-notice (:github_oauth_scopes user) (user-model/missing-scopes user)))
-      (when (seq followed-inaccessible)
+      (when (and (seq followed-inaccessible)
+                 (not (loading-repos-for-vcs-type? user :github))
+                 (not (loading-repos-for-vcs-type? user :bitbucket)))
         (inaccessible-orgs-notice followed-inaccessible settings))
       [:h2 "CircleCI helps you ship better code, faster. Let's add some projects on CircleCI."]
       [:p "To kick things off, you'll need to pick some projects to build:"]


working cljs support

working cljs support

--- src/nrepl_complete/middleware.clj
+++ src/nrepl_complete/middleware.clj
@@ -6,15 +6,12 @@
             [complete.core :as jvm-complete]
             [cljs-complete.core :as cljs-complete]))

-
 (defn grab-cljs-env
   [msg]
   (when-let [piggieback-key (resolve 'cemerick.piggieback/*cljs-repl-env*)]
     (let [session (:session msg)
           env (get @session piggieback-key)]
-      (println session)
-      (println (keys env))
-      (if env  (:cljs.env/compiler env)))))
+      (if env @(:cljs.env/compiler env)))))

 (defn as-sym
   [x]
@@ -24,11 +21,8 @@
   [{:keys [symbol ns public-only? case-sensitive? prefer-ns] :as msg}]
   (let [ns (as-sym ns)
         prefix (str symbol)]
-    (println ns)
-    (println prefix)
     (if-let [cljs-env (grab-cljs-env msg)]
-      (do (println msg)
-        (cljs-complete/completions cljs-env prefix ns))
+      (cljs-complete/completions cljs-env prefix ns)
       (jvm-complete/completions prefix ns))))

 (defn complete-reply


SC Book pp34-38

SC Book pp34-38


(maint) Use instance? over isa?, fn over #().

Change `convert-result-arrays` to use instance? instead of isa? when
checking if the result value is a java.sql.Array, since isa?  also
checks the clojure inheritance hierarchy, which is not necessary in this
case. It's also a little cleaner since it doesn't require calling
`class` on the value as well. Also change the the anonymous function
literal to just an anonymous function, since we prefer the latter.

--- src/puppetlabs/jdbc_util/core.clj
+++ src/puppetlabs/jdbc_util/core.clj
@@ -63,10 +63,10 @@
   ([result-set]
    (convert-result-arrays vec result-set))
   ([f result-set]
-   (let [convert #(cond
-                    (ks/array? %) (f %)
-                    (isa? (class %) java.sql.Array) (f (.getArray %))
-                    :else %)]
+   (let [convert (fn [v] (cond
+                           (ks/array? v) (f v)
+                           (instance? java.sql.Array v) (f (.getArray v))
+                           :else v))]
      (map #(ks/mapvals convert %) result-set))))

 (defn query


Coerce InputStreams with statements function too

--- src/rdf-common/grafter/rdf/io.clj
+++ src/rdf-common/grafter/rdf/io.clj
@@ -438,6 +438,10 @@
                     (merge {:format implied-format} opts)
                     opts)]
       (pr/to-statements (io/reader this) options)))
+
+  java.io.InputStream
+  (pr/to-statements [this opts]
+    (pr/to-statements (io/reader this) opts))

   java.io.Reader
   ;; WARNING: This implementation is necessarily a little convoluted


support :preloads in :node-test target

support :preloads in :node-test target

--- src/main/shadow/build/targets/node_test.clj
+++ src/main/shadow/build/targets/node_test.clj
@@ -36,6 +36,7 @@

         entries
         (-> '[shadow.test.env] ;; must be included before any deftest because of the cljs.test mod
+            (into (:preloads config))
             (into test-namespaces)
             (conj (or (when-let [main (:main config)]
                         (-> main namespace symbol))


Broke lein-midje reporting into several functions.

And made them work.

--- src/midje/ideas/reporting/string_format.clj
+++ src/midje/ideas/reporting/string_format.clj
@@ -5,7 +5,8 @@
         midje.error-handling.exceptions
         [midje.internal-ideas.fact-context :only [format-nested-descriptions]]
         [midje.util.form-utils :only [pred-cond]])
-  (:require [midje.util.colorize :as color]))
+  (:require [midje.util.colorize :as color]
+            [clojure.string :as str]))

 ;;; Formatting Single Fact
@@ -119,54 +120,52 @@

 ;;; Formatting Summary of Facts

-(defn report-strings-summary [exit-after-tests?]
-  `(fn [namespaces#]
-     (let [midje-passes# (:pass @clojure.test/*report-counters*)
-           midje-fails# (:fail @clojure.test/*report-counters*)
-           midje-failure-message# (condp = midje-fails#
-                                    0 (color/pass (format "All claimed facts (%d) have been confirmed." midje-passes#))
-                                    1 (str (color/fail "FAILURE:")
-                                        (format " %d fact was not confirmed." midje-fails#))
-                                    (str (color/fail "FAILURE:")
-                                      (format " %d facts were not confirmed." midje-fails#)))
-
-           potential-consolation# (condp = midje-passes#
-                                    0 ""
-                                    1 "(But 1 was.)"
-                                    (format "(But %d were.)" midje-passes#))
+(defn run-clojure-test [namespaces]
+  (let [output-catcher (java.io.StringWriter.)
+        ct-result (binding [clojure.test/*test-out* output-catcher]
+                             (apply clojure.test/run-tests namespaces))]
+    {:test-count (:test ct-result)
+     :fail-count (+ (:fail ct-result) (:error ct-result))
+     :lines (-> output-catcher .toString str/split-lines)}))

-           midje-consolation# (if (> midje-fails# 0) potential-consolation# "")
+(defn print-clojure-test-result-lines [result]
+  (when (pos? (:fail-count result))
+    (println (color/note ">>> Output from clojure.test tests:"))
+    (dorun (map (comp println color/colorize-deftest-output)
+                (drop-last 2 (:lines result))))))

-           ; Stashed clojure.test output
-           ct-output-catcher# (java.io.StringWriter.)
-           ct-result# (binding [clojure.test/*test-out* ct-output-catcher#]
-                        (apply ~'clojure.test/run-tests namespaces#))
-           ct-output# (-> ct-output-catcher#
-                          .toString
-                          clojure.string/split-lines)
-           ct-failures-and-errors# (+ (:fail ct-result#) (:error ct-result#))
-           ct-some-kind-of-fail?# (> ct-failures-and-errors# 0)]
+(defn print-clojure-test-summary-lines [result]
+  (println (color/note ">>> clojure.test summary:"))
+  (println (first (take-last 2 (:lines result))))
+  (println ( (if (pos? (:fail-count result)) color/fail color/pass)
+             (last (:lines result)))))

-       (when ct-some-kind-of-fail?#
-         ;; For some reason, empty lines are swallowed, so I use >>> to
-         ;; demarcate sections.
-         (println (color/note ">>> Output from clojure.test tests:"))
-         (dorun (map (comp println color/colorize-deftest-output)
-                  (drop-last 2 ct-output#))))
+(defn print-midje-summary-line [result]
+  (let [midje-failure-message (condp = (:fail result)
+                                0 (color/pass (format "All claimed facts (%d) have been confirmed." (:pass result)))
+                                1 (str (color/fail "FAILURE:")
+                                       (format " %d fact was not confirmed." (:fail result)))
+                                (str (color/fail "FAILURE:")
+                                     (format " %d facts were not confirmed." (:fail result))))
+
+        potential-consolation (condp = (:pass result)
+                                0 ""
+                                1 "(But 1 was.)"
+                                (format "(But %d were.)" (:pass result)))

-       (when (> (:test ct-result#) 0)
-         (println (color/note ">>> clojure.test summary:"))
-         (println (first (take-last 2 ct-output#)))
-         (println ( (if ct-some-kind-of-fail?# color/fail color/pass) (last ct-output#)))
-         (println (color/note ">>> Midje summary:")))
+        midje-consolation (if (pos? (:fail result)) potential-consolation "")]
+    (println midje-failure-message midje-consolation)))

-       (println midje-failure-message# midje-consolation#)
-
-       ;; A non-nil return value is printed, so I'll just exit here.
-       (when ~exit-after-tests?
-         (System/exit (+ midje-fails#
-                        (:error ct-result#)
-                        (:fail ct-result#)))))))
+(defn report-strings-summary
+  ([midje-result clojure-test-result]
+     (when (pos? (:test-count clojure-test-result))
+       (print-clojure-test-result-lines clojure-test-result)
+       (print-clojure-test-summary-lines clojure-test-result)
+       (println (color/note ">>> Midje summary:")))
+     (print-midje-summary-line midje-result))
+  ([midje-result]
+     (report-strings-summary midje-result {:test-count 0})))
+

 ;; Config to expose to reporting namespace, which it will use to show
@@ -174,4 +173,4 @@

 (def report-strings-format-config
   { :single-fact-fn report-strings
-    :summary-fn report-strings-summary })+    :summary-fn report-strings-summary })


Removed unused fields

Removed unused fields

--- src/obb_rules/actions/damage_calculator.clj
+++ src/obb_rules/actions/damage_calculator.clj
@@ -7,9 +7,7 @@
   (let [attacker-unit (element-unit attacker-element)
         defender-unit (element-unit defender-element)
         attacker-quantity (element-quantity attacker-element)
-        attack (unit-attack attacker-unit)
-        defender (unit-defense defender-unit)
-        distance-factor 1.0]
+        attack (unit-attack attacker-unit)]
     (* attack attacker-quantity)))

 (defn defense


move the no-zero argument to reflect the top boolean query, not the inner queries, change it from SHOULD to MUST

--- src/bzzz/queries/term_payload_clj_score.clj
+++ src/bzzz/queries/term_payload_clj_score.clj
@@ -33,9 +33,7 @@
                                                                                fixed-bucket-aggregation)
                            clj_context ^ExpressionContext (.clj_context q)]
                        (.set_token_position clj_context n cnt)
-                       (if no-zero
-                         (NoZeroQuery. q)
-                         q)))]
+                       q))]
     (need field "need <field>")
     (need clj-eval "need <clj-eval>")
     (if tokenize
@@ -45,6 +43,8 @@
           (MatchAllDocsQuery.)
           (do
             (doseq [[index token] (indexed tokens)]
-              (.add top (generator token index (count tokens)) BooleanClause$Occur/SHOULD))
-            top)))
+              (.add top (generator token index (count tokens)) BooleanClause$Occur/MUST))
+            (if no-zero
+              (NoZeroQuery. top)
+              top))))
       (generator value 0 1))))


add karma-phantom to doo tests

add karma-phantom to doo tests

--- library/test/clj/test/doo/core.clj
+++ library/test/clj/test/doo/core.clj
@@ -46,7 +46,8 @@
     (are [js-env] (not (doo/valid-js-env? js-env))
          :spidermonkey :browser :browsers :v8 :d8 :something-else)
     (are [js-env] (doo/valid-js-env? js-env)
-         :rhino :nashorn :slimer :phantom :node :chrome :safari :firefox :opera :ie))
+      :rhino :nashorn :slimer :phantom :node
+      :chrome :safari :firefox :opera :ie :karma-phantom))
   (testing "We can resolve aliases"
     (are [alias js-envs] (= (doo/resolve-alias alias {}) js-envs)
          :phantom [:phantom]
@@ -115,12 +116,14 @@
                                      (doo/run-script compiler-opts' doo-opts)
                                      doo-ok?)))
                            (every? true?)))
-           {} [:phantom :chrome :firefox]
+           {} [:phantom :chrome :firefox :karma-phantom]
            {:target :nodejs} [:node]
-           {:optimizations :whitespace} [:rhino :nashorn :phantom :chrome :firefox]
+           {:optimizations :whitespace} [:rhino :nashorn :phantom
+                                         :chrome :firefox :karma-phantom]
            {:optimizations :simple :target :nodejs} [:node]
            {:optimizations :advanced :target :nodejs} [:node]
-           {:optimizations :advanced} [:phantom :rhino :nashorn :chrome :firefox]))))
+           {:optimizations :advanced} [:phantom :rhino :nashorn
+                                       :chrome :firefox :karma-phantom]))))

 (deftest paths-with-options
   (testing "We can pass paths with options"


setIdleTimeout 0 on websocket connection to prevent timeouts

--- src/clj_chrome_devtools/impl/connection.clj
+++ src/clj_chrome_devtools/impl/connection.clj
@@ -106,6 +106,7 @@

     ;; Configure max message size to 1mb (default 64kb is way too small)
     (doto (.getPolicy client)
+      (.setIdleTimeout 0)
       (.setMaxTextMessageSize (* 1024 1024)))

     (.start client)


Add pull-parse function

Add pull-parse function

--- src/clj_simple_chart/ssb/data/ssb_fetch.clj
+++ src/clj_simple_chart/ssb/data/ssb_fetch.clj
@@ -1,5 +1,6 @@
 (ns clj-simple-chart.ssb.data.ssb-fetch
   (:require [clj-http.client :as client]
+            [clojure.set :as set]
             [clj-simple-chart.csv.csvmap :as csv]))

 (def get-memo (memoize client/get))
@@ -51,12 +52,57 @@
 (defn pull-map [table m]
   (pull table (map->query-vector table m)))

+(def pull-map-cached (memoize pull-map))
+
+(defn row-with-time->generic-row [table]
+  (let [v (:valueTexts (variable table "ContentsCode"))
+        all-tid (:valueTexts (variable 11174 "Tid"))]
+    (->> (for [prefix v tid all-tid]
+           [(keyword (str prefix " " tid))
+            (keyword prefix)])
+         (into {}))))
+
+(defn row-with-time->tid [table]
+  (let [v (:valueTexts (variable table "ContentsCode"))
+        all-tid (:valueTexts (variable 11174 "Tid"))]
+    (->> (for [prefix v tid all-tid]
+           [(keyword (str prefix " " tid))
+            tid])
+         (into {}))))
+
+(defn difference [a b]
+  (set/difference (into #{} a) (into #{} b)))
+
+(defn parse-pulled [table pulled]
+  (let [explode-cols-map (row-with-time->generic-row table)
+        tid-map (row-with-time->tid table)
+        explode-cols-cols (keys explode-cols-map)
+        regular-cols (difference (:columns pulled) explode-cols-cols)
+        explode-row (fn [row]
+                      (reduce (fn [o [k v]]
+                                (cond (some #{k} regular-cols) o
+                                      (some #{k} explode-cols-cols)
+                                      (let [new-item (-> (select-keys row regular-cols)
+                                                         (assoc (get explode-cols-map k) v)
+                                                         (assoc :Tid (get tid-map k)))]
+                                        (conj o new-item))
+                                      :else (throw (ex-info (str "Unexpected column") {:column k}))))
+                              [] row))]
+    (->> (:data pulled)
+         (mapcat explode-row)
+         (vec))))
+
+(defn pull-parse [table query-map]
+  (parse-pulled table (pull-map-cached table query-map)))
+
 (def qq {"ContentsCode"  "Salg"
          "Region"        "Hele landet"
          "PetroleumProd" ["Autodiesel" "Bilbensin"]
          "Kjopegrupper"  "Alle kjøpegrupper"
          "Tid"           "*"})

-(def data (pull-map 11174 qq))
+;(def data (pull-map-cached 11174 qq))

-(csv/write-csv "data/ssb/11174.csv" {:columns (:columns data) :data (:data data)})+(def parsed (pull-parse 11174 qq))
+
+;(csv/write-csv "data/ssb/11174.csv" {:columns (:columns data) :data (:data data)})


better form validation

better form validation

--- src/cljs/early_vote_site/election/subs.cljs
+++ src/cljs/early_vote_site/election/subs.cljs
@@ -1,5 +1,6 @@
 (ns early-vote-site.election.subs
-  (:require [re-frame.core :as re-frame]))
+  (:require [clojure.string :as string]
+            [re-frame.core :as re-frame]))

 (re-frame/reg-sub
  :election-form/state
@@ -16,5 +17,5 @@
 (re-frame/reg-sub
  :create-disabled?
  (fn [db]
-   (or (= nil (get-in db [:elections :form :date]))
-       (= "" (get-in db [:elections :form :state])))))
+   (or (string/blank? (get-in db [:elections :form :date]))
+       (string/blank? (get-in db [:elections :form :state])))))


Much faster Sieve of Eratosthenes

Much faster Sieve of Eratosthenes

--- src/clojureplayground/prime_numbers_fun.clj
+++ src/clojureplayground/prime_numbers_fun.clj
@@ -46,13 +46,13 @@
 (defn sieve-of-eratosthenes-revisited
   "Based on a work by @paranoidtimes"
   [n]
-  (let [erathostenes (into-array (replicate n true))]
+  (let [erathostenes (transient (vec (replicate n true)))]
     (doseq [i (range 2 (Math/sqrt n))
-            :let [b (aget erathostenes i)]]
+            :let [b (nth erathostenes i)]]
       (if b
         (loop [j (* i i) k 1]
           (if (< j n)
             (do
-              (aset erathostenes j false)
+              (assoc! erathostenes j false)
               (recur (+ (* i i) (* k i)) (inc k)))))))
-    (filter some? (drop 2 (map-indexed #(if %2 % nil) erathostenes)))))
+    (filter some? (map-indexed #(if %2 % nil) (drop 2 (persistent! erathostenes))))))


CMR-387: Fixed merge conflicts.

CMR-387: Fixed merge conflicts.

--- src/cmr/search/services/query_execution.clj
+++ src/cmr/search/services/query_execution.clj
@@ -143,30 +143,18 @@

 (defmethod execute-query :elastic
   [context query]
-<<<<<<< HEAD
+  (reset! last-query query)
   (let [pre-processed-query (pre-process-query-result-features context query)
         processed-query (r/resolve-collection-queries context pre-processed-query)
         collection-ids (ce/extract-collection-concept-ids processed-query)
         context (assoc context :query-collection-ids collection-ids)
         elastic-results (->> processed-query
                              (c2s/reduce-query context)
-=======
-  (reset! last-query query)
-  (let [; We have to update the binding to the query so changes to the query will be visible when we
-        ; use it subsequently.
-        query (pre-process-query-result-features context query)
-        elastic-results (->> query
-                             c2s/reduce-query
-                             (r/resolve-collection-queries context)
->>>>>>> FETCH_HEAD
                              (#(if (:skip-acls? %)
                                  %
                                  (acl-service/add-acl-conditions-to-query context %)))
                              (idx/execute-query context))
         query-results (rc/elastic-results->query-results context query elastic-results)]
-<<<<<<< HEAD
-    (post-process-query-result-features context pre-processed-query elastic-results query-results)))
-=======
     (post-process-query-result-features context query elastic-results query-results)))

@@ -175,7 +163,6 @@
   (execute-query context @last-query)

-)
+  )

->>>>>>> FETCH_HEAD


nrepl -- fix pprint

nrepl -- fix pprint

--- src/com/billpiel/sayid/nrepl_middleware.clj
+++ src/com/billpiel/sayid/nrepl_middleware.clj
@@ -343,8 +343,11 @@
                   sd/ws-query*
                   first
                   (get-in path'))]
-    (t/send transport (response-for msg :value (clj->nrepl [[nil (so/pprint-str value)]]))))
-  (send-status-done msg))
+    (->> value
+         so/pprint-str
+         vector
+         so/annotated->text-prop-pair
+         (reply:clj->nrepl msg))))

 (defn ^:nrepl sayid-clear-log
   [{:keys [transport] :as msg}]


Using the string/join function for non-lazy evaluation

The use of interpose is useful if we're expecting to produce a lazy seq
seperated by our delimeter. In this case, we were taking this lazy
sequence and converting it into a string (non lazy) anyway.

Rather than add this implicit complexity, use clojure.string/join to do
the interposing of the delimeter using a StringBuilder recursing over
the sequence we provide it.

--- src/com/puppetlabs/puppetdb/scf/storage.clj
+++ src/com/puppetlabs/puppetdb/scf/storage.clj
@@ -23,6 +23,7 @@
             [com.puppetlabs.utils :as utils]
             [com.puppetlabs.jdbc :as jdbc]
             [clojure.java.jdbc :as sql]
+            [clojure.string :as str]
             [clojure.tools.logging :as log]
             [cheshire.core :as json])
   (:use [clj-time.coerce :only [to-timestamp]]
@@ -322,7 +323,7 @@
   {:pre  [(coll? resource-hashes)
           (every? string? resource-hashes)]
    :post [(set? resource-hashes)]}
-  (let [qmarks     (apply str (interpose "," (repeat (count resource-hashes) "?")))
+  (let [qmarks     (str/join "," (repeat (count resource-hashes) "?"))
         query      (format "SELECT DISTINCT resource FROM resource_params WHERE resource IN (%s)" qmarks)
         sql-params (vec (cons query resource-hashes))]
     (sql/with-query-results result-set


Protocol levels from enum

Protocol levels from enum

--- src/clojure/clojurewerkz/cassaforte/client.clj
+++ src/clojure/clojurewerkz/cassaforte/client.clj
@@ -25,7 +25,7 @@
             [clojurewerkz.cassaforte.conversion :as conv])
   (:import [com.datastax.driver.core Statement ResultSet ResultSetFuture Host Session Cluster
             Cluster$Builder SimpleStatement PreparedStatement BoundStatement HostDistance PoolingOptions
-            SSLOptions ProtocolOptions$Compression]
+            SSLOptions ProtocolOptions$Compression ProtocolVersion]
            [com.datastax.driver.auth DseAuthProvider]
            [com.google.common.util.concurrent ListenableFuture Futures FutureCallback]
            [java.net URI]
@@ -130,7 +130,7 @@
     (when port
       (.withPort builder port))
     (when protocol-version
-      (.withProtocolVersion builder protocol-version))
+      (.withProtocolVersion builder (ProtocolVersion/fromInt protocol-version)))
     (when credentials
       (.withCredentials builder (:username credentials) (:password credentials)))
     (when connections-per-host


Remove unused fetch-size macro

Remove unused fetch-size macro

--- src/clojure/clojurewerkz/cassaforte/client.clj
+++ src/clojure/clojurewerkz/cassaforte/client.clj
@@ -36,7 +36,6 @@

 (declare build-ssl-options select-compression)

-(def ^:dynamic *fetch-size*)
 (def ^:dynamic *async* false)

 ;;
@@ -48,12 +47,6 @@
   [body]
   `(binding [*async* true]
      (do ~body)))
-
-(defmacro with-fetch-size
-  "Temporarily alters fetch size."
-  [^Integer n# & body]
-  `(binding [*fetch-size* ~n#]
-     (do ~@body)))

 (defmacro prepare
   "Prepare a single statement, return prepared statement"


Removed some nonsense from proto_much namespace. This is still very much WIP

--- src/tensorflow_clj/proto_much.clj
+++ src/tensorflow_clj/proto_much.clj
@@ -4,29 +4,15 @@
             [tensorflow-clj.util :as util]
             [random-string.core :as randy-str])
   (:import
-    (org.tensorflow.framework.*)
     (org.tensorflow.framework.GraphDef)))

 (def proto-graph-def (proto/protodef org.tensorflow.framework.GraphDef))
 (def graph-node (proto/protodef org.tensorflow.framework.NodeDef))

-(defn write-node [node]
-  (apply
-    (partial proto/protobuf graph-node)
-    (->> node
-         (into [])
-         (apply concat))))
-
-(def linreg-graph (proto/protobuf-load graph (util/slurp-binary "misc/linreg.pb")))
-(-> linreg-graph :node count)
-(map :name (-> linreg-graph :node))
-
-(def addconst-graph (proto/protobuf-load graph (util/slurp-binary "misc/addconst.pb")))
-(-> addconst-graph :node count)
-
-(defn gen-name [prefix]
-  ;(str prefix "_" (randy-str/string 16))
-  prefix)
+(defn gen-name [prefix preserve?]
+  (if preserve?
+    prefix
+    (str prefix "_" (randy-str/string 16))))

 (defn convert-op-key [op-key]
   (-> op-key
@@ -56,24 +42,13 @@
                      :op :mul
                      }
                :add1 {
-                      :op :add
+                      :op :mul
                       }
                :add2 {
                       :op :add
                       }
                }
    })
-
-
-{:node [{:name "Const",
-         :op "Const",
-         :attr [{:key "value", :value {:tensor {:dtype :dt-float, :tensor-shape {}, :float-val [3.0]}}}
-                {:key "dtype", :value {:type :dt-float}}]}
-        {:name "Placeholder",
-         :op "Placeholder",
-         :attr [{:key "dtype", :value {:type :dt-float}} {:key "shape", :value {:shape {}}}]}
-        {:name "mul", :op "Mul", :input ["Const" "Placeholder"], :attr [{:key "T", :value {:type :dt-float}}]}],
- :versions {:producer 21}}

 (defn build-node-def [node-name-map inputs-map key entry]
   (let [attr (case (-> entry :op)
@@ -93,10 +68,15 @@
   (let [keys (map second inputs)]
     (zipmap keys (map first inputs))))

-(defn build-tf-graph [graph-def]
-  (let [{:keys [inputs outputs mappings node-defs]} graph-def
+(defn build-node-name-map [node-keys inputs outputs]
+  (let [preservation-set (into #{} (concat inputs outputs))
+        node-names (map #(gen-name (name %) (contains? preservation-set %)) node-keys)]
+    (zipmap node-keys node-names)))
+
+(defn build-tf-graph [{:keys [inputs outputs mappings node-defs] :as graph-def}]
+  (let [
         node-keys (keys node-defs)
-        node-name-map (zipmap node-keys (map #(-> % name gen-name) node-keys))
+        node-name-map (build-node-name-map node-keys inputs outputs)
         inputs-map (build-inputs-map mappings)
         node-defs (map #(apply (partial build-node-def node-name-map inputs-map) %) node-defs)]
     {:node node-defs
@@ -104,30 +84,34 @@

 (build-tf-graph example-graph)

-(defn write-graph [graph]
-  (apply
-    (partial proto/protobuf proto-graph-def)
-    (->> graph
-         (into [])
-         (apply concat))))
+(defn graph-to-bytes [graph]
+  (let [proto-graph (apply
+                      (partial proto/protobuf proto-graph-def)
+                      (->> graph
+                           (into [])
+                           (apply concat)))]
+    (proto/protobuf-dump proto-graph)))

-(write-graph (build-tf-graph example-graph))
-(write-graph {:node [{:name "Const",
-                      :op "Const",
-                      :attr [{:key "value", :value {:tensor {:dtype "DT_FLOAT", :tensor-shape {}, :float-val [3.0]}}}
-                             {:key "dtype", :value {:type "DT_FLOAT"}}]}
-                     {:name "Placeholder",
-                      :op "Placeholder",
-                      :attr [{:key "dtype", :value {:type "DT_FLOAT"}} {:key "shape", :value {:shape {}}}]}
-                     {:name "mul", :op "Mul", :input ["Const" "Placeholder"], :attr [{:key "T", :value {:type "DT_FLOAT"}}]}],
-              :versions {:producer 21}})
+(def linreg-graph (proto/protobuf-load proto-graph-def (util/slurp-binary "misc/linreg.pb")))
+(-> linreg-graph :node count)
+(map :name (-> linreg-graph :node))
+
+(def addconst-graph (proto/protobuf-load proto-graph-def (util/slurp-binary "misc/addconst.pb")))
+(-> addconst-graph :node count)
+
+{:node [{:name "Const",
+         :op "Const",
+         :attr [{:key "value", :value {:tensor {:dtype :dt-float, :tensor-shape {}, :float-val [3.0]}}}
+                {:key "dtype", :value {:type :dt-float}}]}
+        {:name "Placeholder",
+         :op "Placeholder",
+         :attr [{:key "dtype", :value {:type :dt-float}} {:key "shape", :value {:shape {}}}]}
+        {:name "mul", :op "Mul", :input ["Const" "Placeholder"], :attr [{:key "T", :value {:type :dt-float}}]}],
+ :versions {:producer 21}}

 (exp/exec-graph-sess-fn
   (fn [graph session]
     ;(.importGraphDef graph (util/slurp-binary "misc/addconst.pb"))
     ;(.importGraphDef graph (proto/protobuf-dump addconst-graph))
-    (.importGraphDef graph (proto/protobuf-dump (write-graph (build-tf-graph example-graph))))
-    (exp/run-graph-thing session  {:in1 (float 3.0) :in2 (float 2.0)} :mul)))
-
-(use 'clojure.repl)
-(pst *e)
+    (.importGraphDef graph (graph-to-bytes (build-tf-graph example-graph)))
+    (exp/run-graph-thing session  {:in1 (float 3.0) :in2 (float 3.0)} :mul)))


Trying to account for slow CI

Trying to account for slow CI

--- caching/test/immutant/caching_test.clj
+++ caching/test/immutant/caching_test.clj
@@ -134,9 +134,10 @@
     (is (nil? (:a c)))
     (is (nil? (.putIfAbsent c :a 1)))
     (is (= 1 (:a c)))
+    (.put c :a 1)                       ; reset timer
     (is (= 1 (.putIfAbsent c :a 2)))
     (is (= 1 (:a c)))
-    (Thread/sleep 350)
+    (Thread/sleep 400)
     (is (nil? (:a c)))))

 (deftest test-put-all-ttl


not yet stencil

not yet stencil

--- src/main/clojure/pdok/featured/mustache.clj
+++ src/main/clojure/pdok/featured/mustache.clj
@@ -1,6 +1,5 @@
 (ns pdok.featured.mustache
   (:require [clostache.parser :as clostache]
-            [stencil.core :as stencil]
             [pdok.featured.mustache-functions])
   (:gen-class))


Remove unused server calls

Remove unused server calls

3 unnecessary calls

--- src/webapp/framework/client/coreclient.cljs
+++ src/webapp/framework/client/coreclient.cljs
@@ -387,24 +387,7 @@
                           (<! (remote-fn "!get-record-ui" {})))]
     (reset! record-ui
             record-ui-value))
-
-
-  (let [appshare-dev-server-value (:value
-                                    (<! (remote-fn "!get-appshare-dev-server" {})))]
-    (reset! appshare-dev-server
-            appshare-dev-server-value))
-
-
-  (let [appshare-dev-port-value (:value
-                                  (<! (remote-fn "!get-appshare-dev-port" {})))]
-    (reset! appshare-dev-port
-            appshare-dev-port-value))
-
-
- (let [appshare-cljs-source-value (:value
-                    (<! (remote-fn "!get-appshare-cljs-source" {})))]
-     (reset! appshare-cljs-source
-             appshare-cljs-source-value)))
+)


Remove extra pprint

Remove extra pprint

--- src/yetibot/core/models/users.clj
+++ src/yetibot/core/models/users.clj
@@ -28,7 +28,6 @@
   ([username active? {:keys [id] :as user-info}]
    (let [id (str (or id username))
          mention-name (or (:mention-name user-info) username)] ; use username as the id if nil
-     (clojure.pprint/pprint username)
      (merge user-info {:username username
                        :name username ; alias for backward compat
                        :mention-name mention-name
@@ -58,7 +57,6 @@
    unchanged."
   [chat-source {:keys [id] :as user}]
   (let [user-key {:adapter (:adapter chat-source) :id id}]
-    (clojure.pprint/pprint (:username user))
     (swap! users (add-user-merge chat-source)
            {user-key (merge user {:rooms #{chat-source}})})))


Eliminate some boxed-math warnings

Eliminate some boxed-math warnings

--- src/main/clojure/clojure/test/check/random.clj
+++ src/main/clojure/clojure/test/check/random.clj
@@ -134,7 +134,7 @@
   (rand-long [_]
     (-> state (+ gamma) (mix-64)))
   (rand-double [this]
-    (* double-unit (unsigned-bit-shift-right (rand-long this) 11)))
+    (* double-unit (unsigned-bit-shift-right (long (rand-long this)) 11)))
   (split [this]
     (let [state' (+ gamma state)
           state'' (+ gamma state')
@@ -145,21 +145,22 @@
     ;; immitates a particular series of 2-way splits, but avoids the
     ;; intermediate allocation. See the `split-n-spec` for a test of
     ;; the equivalence to 2-way splits.
-    (case (long n)
-      0 []
-      1 [this]
-      (let [n-dec (dec n)]
-        (loop [state state
-               ret (transient [])]
-          (if (= n-dec (count ret))
-            (-> ret
-                (conj! (JavaUtilSplittableRandom. gamma state))
-                (persistent!))
-            (let [state' (+ gamma state)
-                  state'' (+ gamma state')
-                  gamma' (mix-gamma state'')
-                  new-rng (JavaUtilSplittableRandom. gamma' (mix-64 state'))]
-              (recur state'' (conj! ret new-rng)))))))))
+    (let [n (long n)]
+      (case n
+        0 []
+        1 [this]
+        (let [n-dec (dec n)]
+          (loop [state state
+                 ret (transient [])]
+            (if (= n-dec (count ret))
+              (-> ret
+                  (conj! (JavaUtilSplittableRandom. gamma state))
+                  (persistent!))
+              (let [state' (+ gamma state)
+                    state'' (+ gamma state')
+                    gamma' (mix-gamma state'')
+                    new-rng (JavaUtilSplittableRandom. gamma' (mix-64 state'))]
+                (recur state'' (conj! ret new-rng))))))))))

 (def ^:private golden-gamma
   (longify 0x9e3779b97f4a7c15))


CI test

CI test

Signed-off-by: Chris Granger <5654cde260ae99bc4d30054171b8bcd902efd19a@gmail.com>

--- test/aurora/btree_test.cljs
+++ test/aurora/btree_test.cljs
@@ -198,4 +198,5 @@

 (comment
   (run-all-tests)
+
   )


delaney.clj: API detail changes, more tests, started on (spin) and (unspin)

--- clojure/org/gavrog/clojure/delaney.clj
+++ clojure/org/gavrog/clojure/delaney.clj
@@ -16,7 +16,9 @@
   (dsconj [_ new])
   (dsdisj [_ old])
   (glue [_ i D E])
-  (unglue [_ i D]))
+  (unglue [_ i D])
+  (spin [_ i j D v])
+  (unspin [_ i j D]))

 (extend-type DelaneySymbol
   IDSymbol
@@ -59,31 +61,40 @@
              (= (s ds i D) (s ds j D)) 2
              :else 1)))
   IPersistentDSymbol
-  (dsconj [_ new]
-          (when (and (integer? new) (not (neg? new)))
-            (DSymbol. dim (max size new) s# v#)))
-  (dsdisj [_ old]
-          (when (= old size)
-            (let [s-remove (fn [[i a]]
-                             [i (reduce dissoc a (concat old (map (s# i) old)))])
-                  v-remove (fn [[i a]] [i (reduce dissoc a old)])
-                  new-s# (into {} (map s-remove s#))
-                  new-v# (into {} (map v-remove v#))]
-              (DSymbol. dim (dec size) new-s# new-v#))))
+  (dsconj [_ D]
+          (when (and (integer? D) (pos? D))
+            (DSymbol. dim (max size D) s# v#)))
+  (dsdisj [ds D]
+          (if (element? ds D)
+            (when (= D size)
+              (let [s-remove (fn [[i a]] [i (reduce dissoc a [D ((s# i) D)])])
+                    v-remove (fn [[i a]] [i (dissoc a D)])
+                    new-s# (into {} (map s-remove s#))
+                    new-v# (into {} (map v-remove v#))]
+                (DSymbol. dim (dec size) new-s# new-v#)))
+            ds))
   (glue [ds i D E]
           (when (and (integer? i) (not (neg? i))
                      (integer? D) (pos? D)
-                     (integer? E) (pos? E))
+                     (integer? E) (pos? E)
+                     (= (v ds i (inc i) D) (v ds i (inc i) E))
+                     (= (v ds (dec i) i D) (v ds (dec i) i E)))
             (DSymbol. (max dim i)
                       (max size D E)
                       (assoc s# i (assoc (s# i) D E, E D))
                       v#)))
   (unglue [ds i D]
-            (when (index? ds i)
+            (if (index? ds i)
               (DSymbol. dim
                         size
                         (assoc s# i (dissoc (s# i) D ((s# i) D)))
-                        v#)))
+                        v#)
+              ds))
+  (spin [ds i j D v]
+        (when (and (integer? i) (not (neg? i))
+                   (integer? j) (not (neg? j))
+                   (integer? D) (pos? D))))
+
   Object
   (equals [self other]
           (and (satisfies? IDSymbol other)
@@ -193,6 +204,16 @@

 ;; === Tests

+(deftest add-elements
+  (is (= (dsconj (DSymbol. 0 0 {} {}) 2)
+         (DSymbol. 0 2 {} {}))))
+
+(deftest removing-elements
+  (is (= (dsdisj (DSymbol. 2 2
+                           {0 {1 1, 2 2} 1 {1 2, 2 1} 2 {1 2, 2 1}}
+                           {0 {1 4, 2 4} 1 {1 4, 2 4}}) 2)
+         (DSymbol. 2 1 {0 {1 1} 1 {} 2 {}} {0 {1 4} 1 {1 4}}))))
+
 (deftest gluing
   (is (= (glue (DSymbol. 0 0 {} {}) 2 1 2)
          (DSymbol. 2 2 {2 {1 2 2 1}} {}))))


Comparing for equality should include the default values

--- test/protobuf/core_test.clj
+++ test/protobuf/core_test.clj
@@ -59,7 +59,9 @@
     (let [p (assoc p :tags "aspirin")]
       (is (= ["aspirin"] (:tags p))))
     (let [p (assoc p :foo-by-id {3 {:label "three"} 2 {:label "two"}})]
-      (is (= {3 {:id 3, :label "three"} 2 {:id 2, :label "two"}} (:foo-by-id p))))))
+      (is (= {3 {:id 3, :label "three", :deleted false}
+              2 {:id 2, :label "two", :deleted false}}
+             (:foo-by-id p))))))

 (deftest test-dissoc
   (let [p (protobuf Foo :id 5 :tags ["fast" "shiny"] :label "nice")]
@@ -68,7 +70,7 @@
       (is (= nil (:label p))))))

 (deftest test-equality
-  (let [m {:id 5 :tags ["fast" "shiny"] :label "nice"}
+  (let [m {:id 5 :tags ["fast" "shiny"] :label "nice" :deleted false}
         p (protobuf Foo :id 5 :tags ["fast" "shiny"] :label "nice")
         q (protobuf Foo :id 5 :tags ["fast" "shiny"] :label "nice")]
     (is (= m p))
@@ -308,7 +310,9 @@
         baz (protobuf Foo :id 3 :label "baz")]
     (protobuf-write out foo bar baz)
     (.close out)
-    (is (= [{:id 1, :label "foo"} {:id 2, :label "bar"} {:id 3, :label "baz"}]
+    (is (= [{:id 1, :label "foo", :deleted false}
+            {:id 2, :label "bar", :deleted false}
+            {:id 3, :label "baz", :deleted false}]
            (protobuf-seq Foo in)))))

 (deftest test-encoding-errors


Fixed regression when sending transaction

--- src/status_im/ui/screens/wallet/send/subs.cljs
+++ src/status_im/ui/screens/wallet/send/subs.cljs
@@ -66,7 +66,8 @@
   :<- [:balance]
   (fn [[{:keys [amount to] :as transaction} balance]]
     (assoc transaction :sufficient-funds? (or (nil? amount)
-                                              (money/sufficient-funds? amount balance)))))
+                                              ;; TODO(jeluard) Modify to consider tokens
+                                              (money/sufficient-funds? amount (get balance :ETH))))))

 (re-frame/reg-sub :wallet.send/unsigned-transaction
   :<- [::unsigned-transaction]
@@ -75,7 +76,8 @@
   (fn [[{:keys [value to] :as transaction} contacts balance]]
     (when transaction
       (let [contact           (contacts (utils.hex/normalize-hex to))
-            sufficient-funds? (money/sufficient-funds? value balance)]
+            ;; TODO(jeluard) Modify to consider tokens
+            sufficient-funds? (money/sufficient-funds? value (get balance :ETH))]
         (cond-> (assoc transaction
                        :amount value
                        :sufficient-funds? sufficient-funds?)


worked up to the server-side of protocol tests

--- src/tutorial/untangled_tutorial/K_Testing.cljs
+++ src/tutorial/untangled_tutorial/K_Testing.cljs
@@ -4,12 +4,6 @@
   (:require [devcards.core :as dc :include-macros true :refer-macros [defcard defcard-doc dom-node]]
             [cljs.reader :as r]
             [om.next.impl.parser :as p]))
-
-; TODO: Exercises. The project is set up with tests and such...have them augment.
-; Exercises should include:
-; - Showing them how to make inlined/protocol stuff mockable (e.g. wrap calls in function)
-; - testing unhappy paths/exceptions
-; - Use of all arrow types

 (defcard-doc
   "# Testing
@@ -89,7 +83,7 @@
   The specification macro just outputs a `deftest`, so you are free to use `is`, `are`, etc. The `behavior` macro
   outputs additional events for the renderer to make an outline.

-  ## Exercise 1
+  ### Exercise 1

   Create a new specification `exercises-spec` in `test/client/app/exercises_spec.cljs`. Add a simple specification
   that tests if `2 * 2 = 4`. Remember to update `tests-to-run`. You can use the `ns` preamble from `sample-spec` to
@@ -105,12 +99,12 @@
   The `optional-regex` will match the message of the exception. The optional-predicate is a function that will be given
   the exception instance, and can make additional assertions about the exception.

-  ## Exercise 2
+  ### Exercise 2

   Create an additonal spec (in the same file as before) that uses the `=fn=>` arrow to check that an expression results
   in an even value.

-  ### Mocking
+  ## Mocking

   The mocking system does a lot in a very small space. It can be invoked via the `provided` or `when-mocking` macro.
   The former requires a string and adds an outline section. The latter does not change the outline output.
@@ -158,7 +152,7 @@

   If you were to remove any call to `f` this test would fail with a verify error (`f` not invoked enough).

-  ## Exercise 3
+  ### Exercise 3

   Copy the following code to the top of your testing file:

@@ -214,14 +208,14 @@
       ...body...))
   ```

-  ## Exercise 4
+  ### Exercise 4

   Write more of an integration test for `replace-pairs` that both asserts (via mocking) that `sum-sq` is called,
   but *really* allows the original `sum-sq` to generate the real value. Add assertions that talk about how every result
   is positive, even when the pairs contain negatives. The macro `provided` is the same as `when-mocking`, but allows you
   to add a string to the output (and nest the outline a level deeper) to describe what the mocking is proving.

-  #### Timeline testing
+  ## Timeline testing

   On occasion you'd like to mock things that use callbacks. Chains of callbacks can be a challenge to test, especially
   when you're trying to simulate timing issues.
@@ -289,7 +283,7 @@
   - Seeding that database via a function you supply (which just returns transaction data)
     - Returning a map from temporary ids in your seed data to real datomic ids in the resulting database

-  #### Seed functions
+  ### Seed functions

   Seeding database can be a real pain, particularly when you need to create a graph of data. You have to generate
   tempids, etc. Then, when you want to find your seeded data you have to figure it out somehow!
@@ -342,7 +336,7 @@
        ))
   ```

-  ## Exercise 5
+  ### Exercise 5

   This exercise assumes you know something of the Datomic API. If you don't you might just want to read
   the solution in `db-testing-solutions-spec`.
@@ -420,7 +414,7 @@
     (om/transact! comp '[(a-mutation)]))
   ```

-  ## Exercise 6
+  #### Exercise 6

   Write a test that verifies the UI helper requests the correct mutation

@@ -489,7 +483,7 @@
   The `check-optimistic-delta` uses the `ui-tx` entry to know what to attempt, and the mutations are already
   installed. So, it makes up an app state (which can be based on `initial-ui-state`, if supplied).

-  ## Exercise 7
+  #### Exercise 7

   Check the optimistic update

@@ -508,7 +502,9 @@
   `(a-mutation)` is a perfect thing to say to the UI, but when sending it to the server you must add in
   a parameter (e.g. reference ID, auth info, etc.).

-  #### **Exercise**: Check that a mutation is sent to the server
+  #### Exercise 8
+
+  Check that a mutation is sent to the server.

   This test is again mostly automated for you. Simply call `(ps/check-server-tx do-a-mutation-protocol)` after
   setting `:server-tx value` in your protocol.
@@ -523,10 +519,12 @@

   Add `:remote true` to your return value from `a-mutation`. The test should now pass.

-  #### **Exercise**: Mutations that modify the ui-tx
+  #### Exercise 9
+
+  Test a mutations that modifies the ui-tx.

   As you probably already know, it is possible to modify the mutation sent to the server by giving an AST
-  as the value of `:remote`. Add a parameter to the transaction by modifying the mutation to:
+  as the value of `:remote` instead of `true`. Add a parameter to the transaction by modifying the mutation to:

   ```
    (defmethod m/mutate 'a-mutation [{:keys [state ast] :as env} k params]


Missing unit test for transpose

Missing unit test for transpose


Fix JDBC connection pool test on Postgres

When using Postgres as the test database, there's no guarantee the user this
test is trying to connect as exists. If it doesn't, the test hangs, trying
perpetually to connect. Given that the only thing we care about is that we can
build the appropriate connection pool, there's no need to actually connect. So
now we just build the object and go on, so this will work on both test
databases.

--- test/com/puppetlabs/test/jdbc.clj
+++ test/com/puppetlabs/test/jdbc.clj
@@ -39,8 +39,6 @@
     (let [pool (-> (test-db)
                    (assoc :username 1234 :password 1234)
                    (subject/pooled-datasource))]
-      (subject/with-transacted-connection pool
-        (sql/create-table :test [:foo "INT"]))
       (.close (:datasource pool)))))

 (deftest query-to-vec