Skip to content

Commit

Permalink
minimal js API working - just encoders, htm-step, state-freqs so far.
Browse files Browse the repository at this point in the history
  • Loading branch information
floybix committed Aug 12, 2016
1 parent 9c4faf1 commit bdee3ce
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 312 deletions.
33 changes: 24 additions & 9 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,34 @@
[org.clojure/core.async "0.2.374"]
[org.clojure/data.int-map "0.2.1"]
[org.clojure/test.check "0.9.0"]
[org.clojure/clojurescript "1.9.36"]
[clj-http "2.0.0"]
[cljs-http "0.1.38"]]

:jvm-opts ^:replace ["-server" "-Xmx2500m"]

:cljsbuild {:builds [{:jar true
:compiler {:output-to "target/testable.js"
:optimizations :advanced}}]}
:plugins [[lein-cljsbuild "1.1.3"]]

:profiles {:dev {:dependencies [[org.clojure/clojurescript "1.7.189"]
[criterium "0.4.3"]]
:plugins [[lein-cljsbuild "1.1.0"]
[com.cemerick/clojurescript.test "0.3.3"]
;[lein-marginalia "0.8.1-SNAPSHOT"]
]}
:clean-targets ["public/comportex.js" "public/out"]

:cljsbuild {:builds
{:main
{:source-paths ["src"]
:jar true
:compiler {:output-dir "public/out"
:output-to "public/comportex.js"}}}}

:profiles {:dev {:dependencies [[criterium "0.4.3"]]
;:plugins [[lein-marginalia "0.9.0"]]
:cljsbuild {:builds
{:main
{:compiler
{:optimizations :none
:source-map true}}}}}
;; Use: "lein with-profile +prod cljsbuild once"
:prod {:cljsbuild {:builds
{:main
{:compiler
{:optimizations :advanced
:source-map "public/comportex.js.map"}}}}}
:repl {:source-paths ["dev" "src"]}})
35 changes: 35 additions & 0 deletions public/comportexjs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<html>
<body>
<script src="out/goog/base.js" type="text/javascript"></script>
<script src="comportex.js" type="text/javascript"></script>
<script type="text/javascript">goog.require("org.nfrac.comportex.js");</script>

<p>Comportex from Javascript. Look at the js source!</p>

<pre id="content" />

<script type="text/javascript">
comportex = org.nfrac.comportex.js;
out = "";
e = comportex.linear_encoder([100], 20, 0, 25);
out += "linear encoding bits: \n";
out += comportex.encode(e, 10);
out += "\n";
inputs = [{"value": 1, "index": 0},
{"value": 2, "index": 1},
{"value": 3, "index": 2}];
spec = {"column-dimensions": [1000],
"proximal": {"stimulus-threshold": 1}};
out += "spec: " + JSON.stringify(spec) + "\n";
sensor = ["value", e];
model = comportex.regions_in_series(1, [spec], {"input": sensor});
out += "inval: " + JSON.stringify(inputs[0]) + "\n";
model_1 = comportex.htm_step(model, inputs[0]);
out += "timestep: " + comportex.timestep(model_1) + "\n";
out += "column state freqs: " +
JSON.stringify(
comportex.column_state_freqs(comportex.region_seq(model_1)[0]));
document.getElementById("content").innerHTML = out;
</script>
</body>
</html>
303 changes: 0 additions & 303 deletions src/org/nfrac/comportex/js.cljc

This file was deleted.

Loading

0 comments on commit bdee3ce

Please sign in to comment.