Skip to content

Commit

Permalink
js API expose params function.
Browse files Browse the repository at this point in the history
  • Loading branch information
floybix committed Aug 13, 2016
1 parent 9408cd0 commit 330ecae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions public/comportexjs.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
out += "bursting columns: " + comportex.bursting_columns(lyr).sort() + "\n";
out += "active cells: " + JSON.stringify(comportex.active_cells(lyr)) + "\n";
out += "predictive cells: " + JSON.stringify(comportex.predictive_cells(lyr)) + "\n";
out += "spec: \n";
out += JSON.stringify(comportex.params(lyr));
document.getElementById("content").innerHTML = out;
</script>
</body>
Expand Down
11 changes: 8 additions & 3 deletions src/org/nfrac/comportex/js.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
;; TODO: handle keyword values such as for :spatial-pooling key
(js->clj spec :keywordize-keys true))

(defn spec->js
[spec]
(clj->js spec))

(defn js->selector
[selector]
(cond
Expand Down Expand Up @@ -119,16 +123,17 @@
[htm sense-id n-predictions]
(clj->js (core/predictions htm (keyword sense-id) n-predictions)))

;; protocols
;; mostly just protocols (ie. interfaces)

(defn ^:export htm-step
"Compute the next time step. Pass `htm` as a clojure object, but `inval` as
a js value which will be converted to a clojurescript value, including
keywordizing keys."
[htm inval]
(p/htm-step htm (js->clj inval :keywordize-keys true)))

(defn ^:export params
[rgn-or-lyr]
(spec->js (p/params rgn-or-lyr)))

(defn ^:export encode
[encoder x]
(clj->js (p/encode encoder (js->clj x))))
Expand Down

0 comments on commit 330ecae

Please sign in to comment.