-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit - have a pathway to dev and test.
- Loading branch information
0 parents
commit 886f1d5
Showing
13 changed files
with
668 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
.cpcache | ||
.shadow-cljs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# DataFrame and Numerics for ClojureScript | ||
|
||
## Development | ||
|
||
This is what I have so far to make development quick | ||
|
||
### Get a REPL | ||
|
||
* clj -M:cljs node-repl | ||
* cider-connect to port 8777 once it starts | ||
* `(shadow/repl :node-repl)` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{:paths ["src"] | ||
:deps {} | ||
:aliases | ||
{:cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.12.4"} | ||
cider/cider-nrepl {:mvn/version "0.26.0"}} | ||
:main-opts ["-m" "shadow.cljs.devtools.cli"]}}} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"dependencies": { | ||
"react": "17.0.2", | ||
"react-dom": "^17.0.2", | ||
"ws": "^7.5.3" | ||
}, | ||
"devDependencies": { | ||
"source-map-support": "^0.5.19" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{:deps true | ||
;; set an nrepl port for connection to a REPL. | ||
:nrepl {:port 8777} | ||
:builds {:app {:target :node-library | ||
;;module :app will output data to app.js | ||
:modules {:app {:init-fn tmdjs/init}} | ||
:output-dir "resources/public/js" | ||
:output-to "resources/public/js" | ||
:asset-path "js" | ||
:devtools {:http-root "resources/public" | ||
:http-port 8700}}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
(ns accent.arrays | ||
"Taken from https://github.com/skrat/accent/blob/master/src/accent/arrays.cljs" | ||
(:refer-clojure :exclude [concat])) | ||
|
||
(def all-array-types | ||
[js/Int8Array | ||
js/Uint8Array | ||
js/Uint8ClampedArray | ||
js/Int16Array | ||
js/Uint16Array | ||
js/Int32Array | ||
js/Uint32Array | ||
js/Float32Array | ||
js/Float64Array]) | ||
|
||
|
||
(defn extend-array-type | ||
[t] | ||
(extend-type t | ||
ISequential | ||
ISeqable | ||
(-seq [array] (array-seq array)) | ||
ISeq | ||
(-first [array] (aget array 0)) | ||
(-rest [array] (.subarray array 1)) | ||
IIndexed | ||
(-nth | ||
([array n] | ||
(aget array n)) | ||
([array n not-found] | ||
(if (< n (count array)) | ||
(aget array n) | ||
not-found))) | ||
ICounted | ||
(-count [array] (.-length array)) | ||
IReduce | ||
(-reduce | ||
([array f] (array-reduce array f)) | ||
([array f start] (array-reduce array f start))) | ||
IPrintWithWriter | ||
(-pr-writer [array writer opts] | ||
(-write writer (str "#" | ||
(.. array -constructor -name) | ||
(array-seq array)))))) | ||
|
||
|
||
(doseq [t all-array-types] | ||
(extend-array-type t)) | ||
|
||
(defn int8 | ||
"Creates a native Int8Array for a given `collection`." | ||
[collection] | ||
(js/Int8Array. (clj->js collection))) | ||
|
||
(defn unsigned-int8 | ||
"Creates a native Uint8Array for a given `collection`." | ||
[collection] | ||
(js/Uint8Array. (clj->js collection))) | ||
|
||
(defn unsigned-int8-clamped | ||
"Creates a native Uint8ClampedArray for a given `collection`." | ||
[collection] | ||
(js/Uint8ClampedArray. (clj->js collection))) | ||
|
||
(defn int16 | ||
"Creates a native Int16Array for a given `collection`." | ||
[collection] | ||
(js/Int16Array. (clj->js collection))) | ||
|
||
(defn unsigned-int16 | ||
"Creates a native Uint16Array for a given `collection`." | ||
[collection] | ||
(js/Uint16Array. (clj->js collection))) | ||
|
||
(defn int32 | ||
"Creates a native Int32Array for a given `collection`." | ||
[collection] | ||
(js/Int32Array. (clj->js collection))) | ||
|
||
(defn unsigned-int32 | ||
"Creates a native Uint32Array for a given `collection`." | ||
[collection] | ||
(js/Uint32Array. (clj->js collection))) | ||
|
||
(defn float32 | ||
"Creates a native Float32Array for a given `collection`." | ||
[collection] | ||
(js/Float32Array. (clj->js collection))) | ||
|
||
(defn float64 | ||
"Creates a native Float64Array for a given `collection`." | ||
[collection] | ||
(js/Float64Array. (clj->js collection))) | ||
|
||
(defn typed-array? | ||
"Tests whether a given `value` is a typed array." | ||
[value] | ||
(some #{(type value)} all-array-types)) | ||
|
||
(defn ->clj | ||
[collection] | ||
(if (typed-array? collection) | ||
(js->clj (js/Array.apply nil collection)) | ||
collection)) | ||
|
||
(defn concat | ||
[a & as] | ||
(let [all (cons a as) | ||
sizes (map count all) | ||
outsize (reduce + sizes) | ||
out (js* "new a.constructor(outsize)")] | ||
(loop [arrays all | ||
offset 0] | ||
(if-not (zero? (count arrays)) | ||
(let [array (first arrays) | ||
size (count array)] | ||
(.set out array offset) | ||
(recur (rest arrays) (+ offset size))) | ||
out)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
(ns tech.v3.datatype | ||
(:require [tech.v3.datatype.protocols :as dtype-proto] | ||
[tech.v3.datatype.base :as dt-base] | ||
[tech.v3.datatype.copy-make-container :as dt-cmc]) | ||
(:refer-clojure :exclude [clone counted?])) | ||
|
||
(defn ecount | ||
[item] | ||
(if item | ||
;;As count is a protocol in js, we have no reason to define our own | ||
(count item) | ||
0)) | ||
|
||
|
||
(defn clone | ||
"Here for compat with jvm system" | ||
[item] | ||
(cljs.core/clone item)) | ||
|
||
|
||
(defn elemwise-datatype | ||
[item] | ||
(if item | ||
(dtype-proto/-elemwise-datatype item) | ||
:object)) | ||
|
||
|
||
(defn datatype | ||
[item] | ||
(if item | ||
(dtype-proto/-datatype item) | ||
:object)) | ||
|
||
(defn as-typed-array | ||
[item] | ||
(dt-base/as-typed-array item)) | ||
|
||
|
||
(defn as-js-array | ||
[item] | ||
(dt-base/as-js-array item)) | ||
|
||
|
||
(defn sub-buffer-copy | ||
"Create a copy of the data in the item from offset till len." | ||
[item off & [len]] | ||
(dt-base/sub-buffer-copy item off len)) | ||
|
||
|
||
(defn counted? | ||
[item] | ||
(dt-base/counted? item)) | ||
|
||
|
||
(defn set-value! | ||
[item idx data] | ||
(dt-base/set-value! item idx data)) | ||
|
||
|
||
(defn copy! | ||
[src dest] | ||
(set-value! dest 0 src)) | ||
|
||
|
||
(defn make-container | ||
"Return a packed container of data. Container implements count, nth, and meta, | ||
with-meta, and elemwise-datatype. Uses typed-arrays for most primitive types and | ||
generic js arrays for anything else. The container itself cannot check that the input | ||
matches the datatype so that form of checking is not available in the js version | ||
(unlike the jvm version)." | ||
[dtype len-or-data] | ||
(dt-cmc/make-container dtype len-or-data)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
(ns tech.v3.datatype.argops | ||
(:require [tech.v3.datatype.base :as dt-base] | ||
[tech.v3.datatype.copy-make-container :as dt-cmc])) | ||
|
||
|
||
(defn argsort | ||
([compare-fn data] | ||
(let [comp (if compare-fn | ||
(comparator compare-fn) | ||
compare) | ||
data (dt-base/ensure-indexable data) | ||
n-data (count data) | ||
indexes (dt-cmc/make-container :int32 (range n-data)) | ||
idx-ary (dt-base/as-typed-array indexes)] | ||
(if-let [data (dt-base/as-agetable data)] | ||
(.sort idx-ary #(comp (aget data %1) (aget data %2))) | ||
(.sort idx-ary #(comp (nth data %1) (nth data %2)))) | ||
indexes)) | ||
([data] | ||
(argsort nil data))) | ||
|
||
|
||
(defn argfilter | ||
[pred data] | ||
(let [data (dt-base/ensure-indexable data) | ||
n-data (count data) | ||
indexes (dt-cmc/make-container :int32 (range n-data)) | ||
idx-ary (dt-base/as-typed-array indexes)] | ||
(if-let [data (dt-base/as-agetable data)] | ||
(.filter idx-ary #(boolean (pred (aget data %)))) | ||
(.filter idx-ary #(boolean (pred (nth data %))))))) |
Oops, something went wrong.