From 42d7ff5fb92649cb1becc5d8de3bd172000fb391 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Tue, 7 May 2024 16:52:33 +0200 Subject: [PATCH 01/19] did the binary ones --- src/clojisr/v1/r.clj | 64 ++++++++++++++++++++++---------------- test/clojisr/v1/r_test.clj | 3 ++ 2 files changed, 41 insertions(+), 26 deletions(-) create mode 100644 test/clojisr/v1/r_test.clj diff --git a/src/clojisr/v1/r.clj b/src/clojisr/v1/r.clj index 209e96e..215566e 100644 --- a/src/clojisr/v1/r.clj +++ b/src/clojisr/v1/r.clj @@ -124,30 +124,38 @@ (r (format fmt n (name package))) (intern *ns* ns (r ns))))) -(def r== (r "`==`")) -(def r!= (r "`!=`")) -(def r< (r "`<`")) -(def r> (r "`>`")) -(def r<= (r "`<=`")) -(def r>= (r "`>=`")) -(def r& (r "`&`")) -(def r&& (r "`&&`")) -(def r| (r "`||`")) -(def r|| (r "`||`")) -(def r! (r "`!`")) -(def r$ (r "`$`")) - -(def captured-str - "For the R function [str](https://www.rdocumentation.org/packages/utils/versions/3.6.1/topics/str), we capture the standard output and return the corresponding string." - (r "function(x) capture.output(str(x))")) - -(def println-captured-str (comp println-r-lines captured-str)) - -(def str-md (comp r-lines->md captured-str)) - -(def r** (r "`^`")) -(def rdiv (r "`/`")) -(def r- (r "`-`")) +(run! + (fn [op] (intern *ns* (symbol (format "r%s" op)) + (fn [e1 e2] + ((clojisr.v1.r/r (format "`%s`" op)) e1 e2)))) + ["==", "!=" "<" ">" "<=" ">=" "r&" "r&&" "r|" "r||" "r!" "r$"]) + + + +;; (def r== (r "`==`")) +;; (def r!= (r "`!=`")) +;; (def r< (r "`<`")) +;; (def r> (r "`>`")) +;; (def r<= (r "`<=`")) +;; (def r>= (r "`>=`")) +;; (def r& (r "`&`")) +;; (def r&& (r "`&&`")) +;; (def r| (r "`||`")) +;; (def r|| (r "`||`")) +;; (def r! (r "`!`")) +;; (def r$ (r "`$`")) + +;; (def captured-str +;; "For the R function [str](https://www.rdocumentation.org/packages/utils/versions/3.6.1/topics/str), we capture the standard output and return the corresponding string." +;; (r "function(x) capture.output(str(x))")) + +;; (def println-captured-str (comp println-r-lines captured-str)) + +;; (def str-md (comp r-lines->md captured-str)) + +;; (def r** (r "`^`")) +;; (def rdiv (r "`/`")) +;; (def r- (r "`-`")) (defn r* [& args] (reduce (r "`*`") args)) (defn r+ "The plus operator is a binary one, and we want to use it on an arbitraty number of arguments." @@ -155,7 +163,7 @@ (reduce (r "`+`") args)) ;; Some special characters will get a name in letters. -(def colon (r "`:`")) +;; (def colon (r "`:`")) ;; @@ -194,7 +202,7 @@ (let [fixed# (prepare-args-for-bra pars# ~all?)] (apply bra# fixed#))))))) -(make-bras) +;; (make-bras) ;; register shutdown hook ;; should be called once @@ -222,3 +230,7 @@ "Prints help for an R object or function" ([r-object] (println (help r-object))) ([function package] (println (help function package)))) + + +(println (r<= 1 1)) +(println "success") diff --git a/test/clojisr/v1/r_test.clj b/test/clojisr/v1/r_test.clj new file mode 100644 index 0000000..3cf012e --- /dev/null +++ b/test/clojisr/v1/r_test.clj @@ -0,0 +1,3 @@ +(ns clojisr.v1.r-test + (:require [clojisr.v1.r :as sut] + [clojure.test :as t])) gg From 51aa30e07f38c34261c86d158f4ab1987c802091 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Tue, 7 May 2024 17:32:44 +0200 Subject: [PATCH 02/19] refactored --- src/clojisr/v1/r.clj | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/clojisr/v1/r.clj b/src/clojisr/v1/r.clj index 215566e..3efa70b 100644 --- a/src/clojisr/v1/r.clj +++ b/src/clojisr/v1/r.clj @@ -124,11 +124,14 @@ (r (format fmt n (name package))) (intern *ns* ns (r ns))))) +(defn- intern-r [clj-op op] + (intern *ns* (symbol clj-op) + (fn [e1 e2] + ((clojisr.v1.r/r (format "`%s`" op)) e1 e2)))) + (run! - (fn [op] (intern *ns* (symbol (format "r%s" op)) - (fn [e1 e2] - ((clojisr.v1.r/r (format "`%s`" op)) e1 e2)))) - ["==", "!=" "<" ">" "<=" ">=" "r&" "r&&" "r|" "r||" "r!" "r$"]) + (fn [op] (intern-r (str "r" op) op)) + ["==", "!=" "<" ">" "<=" ">=" "r&" "r&&" "r|" "r||" "r!" "r$" "-"]) @@ -153,9 +156,14 @@ ;; (def str-md (comp r-lines->md captured-str)) +(intern-r "r**" "^") + ;; (def r** (r "`^`")) +(intern-r "rdiv" "/") ;; (def rdiv (r "`/`")) + ;; (def r- (r "`-`")) + (defn r* [& args] (reduce (r "`*`") args)) (defn r+ "The plus operator is a binary one, and we want to use it on an arbitraty number of arguments." @@ -164,7 +172,7 @@ ;; Some special characters will get a name in letters. ;; (def colon (r "`:`")) - +(intern-r "colon" ":") ;; (defmacro defr From ee88ce2c54dec9d3458313294b7a95d3d72c3e58 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Tue, 7 May 2024 15:34:00 +0000 Subject: [PATCH 03/19] refcatored --- src/clojisr/v1/r.clj | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/clojisr/v1/r.clj b/src/clojisr/v1/r.clj index 215566e..63c5803 100644 --- a/src/clojisr/v1/r.clj +++ b/src/clojisr/v1/r.clj @@ -128,7 +128,7 @@ (fn [op] (intern *ns* (symbol (format "r%s" op)) (fn [e1 e2] ((clojisr.v1.r/r (format "`%s`" op)) e1 e2)))) - ["==", "!=" "<" ">" "<=" ">=" "r&" "r&&" "r|" "r||" "r!" "r$"]) + ["==" "!=" "<" ">" "<=" ">=" "&" "&&" "|" "||" "!" "$"]) @@ -202,7 +202,7 @@ (let [fixed# (prepare-args-for-bra pars# ~all?)] (apply bra# fixed#))))))) -;; (make-bras) +;(make-bras) ;; register shutdown hook ;; should be called once @@ -232,5 +232,5 @@ ([function package] (println (help function package)))) -(println (r<= 1 1)) + (println "success") From a58b5e9c9b7ef11266561445bb9f761722a54016 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Tue, 7 May 2024 18:27:12 +0200 Subject: [PATCH 04/19] added quarto and leiningen --- .devcontainer/devcontainer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 774c7f5..2ca56d8 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -8,7 +8,9 @@ "features": { "ghcr.io/devcontainers-contrib/features/clojure-asdf:2": {}, - "ghcr.io/rocker-org/devcontainer-features/r-apt:0": {} + "ghcr.io/rocker-org/devcontainer-features/r-apt:0": {}, + "ghcr.io/devcontainers-contrib/features/leiningen-sdkman:2": {}, + "ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": {} }, @@ -20,7 +22,6 @@ "extensions": [ "vscjava.vscode-java-pack", - "borkdude.clj-kondo", "betterthantomorrow.calva" ] } From 273dbb16f66c3eba5fd20ad3f781bdd1b5c32f9c Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Tue, 7 May 2024 16:29:08 +0000 Subject: [PATCH 05/19] made r_xxx functions as defn --- src/clojisr/v1/r.clj | 34 +++++++++++++++++++-------------- test/clojisr/v1/r_test.clj | 39 ++++++++++++++++++++++---------------- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/src/clojisr/v1/r.clj b/src/clojisr/v1/r.clj index f83a1f1..2e27b23 100644 --- a/src/clojisr/v1/r.clj +++ b/src/clojisr/v1/r.clj @@ -124,15 +124,20 @@ (r (format fmt n (name package))) (intern *ns* ns (r ns))))) -(defn- intern-r [clj-op op] +(defn- intern-r-binary [clj-op op] (intern *ns* (symbol clj-op) - (fn [e1 e2] - ((clojisr.v1.r/r (format "`%s`" op)) e1 e2)))) + (fn [e1 e2] + ((clojisr.v1.r/r (format "`%s`" op)) e1 e2)))) (run! - (fn [op] (intern-r (str "r" op) op)) - ["==", "!=" "<" ">" "<=" ">=" "r&" "r&&" "r|" "r||" "r!" "r$" "-"]) + (fn [op] (intern-r-binary (str "r" op) op)) + ["==", "!=" "<" ">" "<=" ">=" "&" "&&" "|" "||" + ;"r!" + "$" "-"]) +(intern *ns* (symbol "r!") + (fn [e] + ((clojisr.v1.r/r "`!`") e))) ;; (def r== (r "`==`")) @@ -148,23 +153,24 @@ ;; (def r! (r "`!`")) ;; (def r$ (r "`$`")) -;; (def captured-str -;; "For the R function [str](https://www.rdocumentation.org/packages/utils/versions/3.6.1/topics/str), we capture the standard output and return the corresponding string." -;; (r "function(x) capture.output(str(x))")) + (def captured-str + "For the R function [str](https://www.rdocumentation.org/packages/utils/versions/3.6.1/topics/str), we capture the standard output and return the corresponding string." + (r "function(x) capture.output(str(x))")) -;; (def println-captured-str (comp println-r-lines captured-str)) + (def println-captured-str (comp println-r-lines captured-str)) -;; (def str-md (comp r-lines->md captured-str)) + (def str-md (comp r-lines->md captured-str)) -(intern-r "r**" "^") +(intern-r-binary "r**" "^") ;; (def r** (r "`^`")) -(intern-r "rdiv" "/") +(intern-r-binary "rdiv" "/") ;; (def rdiv (r "`/`")) ;; (def r- (r "`-`")) (defn r* [& args] (reduce (r "`*`") args)) + (defn r+ "The plus operator is a binary one, and we want to use it on an arbitraty number of arguments." [& args] @@ -172,7 +178,7 @@ ;; Some special characters will get a name in letters. ;; (def colon (r "`:`")) -(intern-r "colon" ":") +(intern-r-binary "colon" ":") ;; (defmacro defr @@ -210,7 +216,7 @@ (let [fixed# (prepare-args-for-bra pars# ~all?)] (apply bra# fixed#))))))) -;(make-bras) +(make-bras) ;; register shutdown hook ;; should be called once diff --git a/test/clojisr/v1/r_test.clj b/test/clojisr/v1/r_test.clj index a97b2b7..f5aae8a 100644 --- a/test/clojisr/v1/r_test.clj +++ b/test/clojisr/v1/r_test.clj @@ -1,25 +1,24 @@ (ns clojisr.v1.r-test (:require [clojisr.v1.r :as r] + + [clojisr.v1.require :as require-r] [clojure.test :refer [is deftest] :as t])) +(require-r/require-r '[datasets]) + (def v [1 2 3]) -(deftest binaries - (is true - (first - (r/r->clj - (r/r== 1 1))))) - - (deftest bras + (is (= [1] + (-> (r/bra v 1) r/r->clj))) (is (= [1] (-> (r/brabra v 1) r/r->clj)))) (deftest binaries - (is (= [true false false false true true true true true true] + (is (= [true false false false true true true true true true 0 2 1 1.0 1] (map (fn [f] @@ -35,13 +34,21 @@ r/r&& r/r| r/r|| + r/r- + r/r+ + r/r* + r/rdiv + r/colon ])))) - ;r/r! - ;r/r$ - -(first (r/r->clj (r/r! true))) -r/r -r/r+ -r/r* -r/r== +(deftest unary + (is (not + (first (r/r->clj (r/r! true)))))) + +(deftest bra-colon + (is (= [21.0 22.8 21.4] + (-> r.datasets/mtcars + (r/r$ "mpg") + (r/bra (r/colon 2 4)) + (r/r->clj) + )))) From 0785d590a84716886c45c57eed1e815e0529f262 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Tue, 7 May 2024 16:30:03 +0000 Subject: [PATCH 06/19] all test tests for leiningen --- .gitignore | 1 + deps.edn | 3 ++- project.clj | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f478dd0..54edb37 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ pom.xml.asc .clay* *qmd .clerk +.calva diff --git a/deps.edn b/deps.edn index c75cccf..9d2129b 100644 --- a/deps.edn +++ b/deps.edn @@ -12,7 +12,8 @@ :extra-deps {org.scicloj/clay {:mvn/version "2-beta8"} io.github.nextjournal/clerk {:mvn/version "0.7.418"}}} :test {:extra-paths ["test"] - :extra-deps {io.github.cognitect-labs/test-runner + :extra-deps {org.scicloj/clay {:mvn/version "2-beta8"} + io.github.cognitect-labs/test-runner {:git/tag "v0.5.0" :git/sha "b3fd0d2"}} :main-opts ["-m" "cognitect.test-runner"] :exec-fn cognitect.test-runner.api/test}}} diff --git a/project.clj b/project.clj index 3edc1ae..8e9a294 100644 --- a/project.clj +++ b/project.clj @@ -4,8 +4,11 @@ :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0" :url "https://www.eclipse.org/legal/epl-2.0/"} :plugins [[lein-tools-deps "0.4.5"]] - :test-paths ["notebooks"] + :test-paths ["test","notebooks"] :middleware [lein-tools-deps.plugin/resolve-dependencies-with-deps-edn] ;; :repositories {"bedatadriven" {:url "https://nexus.bedatadriven.com/content/groups/public/"}} :lein-tools-deps/config {:config-files [:install :user :project]} + :profiles { + :test {:dependencies [[org.scicloj/clay "2-beta8"]]}} + :jvm-opts ["-Dclojure.tools.logging.factory=clojure.tools.logging.impl/jul-factory"]) From 4c1d413da05a1b954bae7996e5ddd90fb1994f0a Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Tue, 7 May 2024 16:59:42 +0000 Subject: [PATCH 07/19] fixed leiningen addition --- .devcontainer/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index dba59a3..a1d3163 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,5 +2,4 @@ FROM mcr.microsoft.com/devcontainers/java:11-bullseye RUN bash -c "bash < <(curl -s https://raw.githubusercontent.com/babashka/babashka/master/install)" RUN bash -c "bash < <(curl -s https://raw.githubusercontent.com/clojure-lsp/clojure-lsp/master/install)" -RUN apt-get update && apt-get install -y rlwrap gfortran libblas-dev liblapack-dev libpng-dev libfontconfig1-dev libfreetype-dev gfortran libicu-dev cmake -RUN apt-get install leiningen \ No newline at end of file +RUN apt-get update && apt-get install -y rlwrap gfortran libblas-dev liblapack-dev libpng-dev libfontconfig1-dev libfreetype-dev gfortran libicu-dev cmake leiningen From e7422b584f195323f787009bade4fdf31f795d3a Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Tue, 7 May 2024 18:26:13 +0000 Subject: [PATCH 08/19] worked on str-md --- src/clojisr/v1/r.clj | 29 +++++++++++++++++++++++------ test/clojisr/v1/r_test.clj | 18 +++++++++++++++--- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/clojisr/v1/r.clj b/src/clojisr/v1/r.clj index 2e27b23..e1be463 100644 --- a/src/clojisr/v1/r.clj +++ b/src/clojisr/v1/r.clj @@ -153,13 +153,30 @@ ;; (def r! (r "`!`")) ;; (def r$ (r "`$`")) - (def captured-str + + + + (defn- captured-str [] "For the R function [str](https://www.rdocumentation.org/packages/utils/versions/3.6.1/topics/str), we capture the standard output and return the corresponding string." - (r "function(x) capture.output(str(x))")) + (r "function(x) capture.output(str(x))") ) + + (defn println-captured-str[x] + (def x x) + (-> + (apply-function + (captured-str) + [x]) + println-r-lines)) - (def println-captured-str (comp println-r-lines captured-str)) + (defn str-md [x] + (-> + (apply-function + (captured-str) + [x]) + r-lines->md)) - (def str-md (comp r-lines->md captured-str)) + + (intern-r-binary "r**" "^") @@ -218,6 +235,8 @@ (make-bras) + + ;; register shutdown hook ;; should be called once (defonce ^:private shutdown-hook-registered @@ -246,5 +265,3 @@ ([function package] (println (help function package)))) - -(println "success") diff --git a/test/clojisr/v1/r_test.clj b/test/clojisr/v1/r_test.clj index f5aae8a..909cabc 100644 --- a/test/clojisr/v1/r_test.clj +++ b/test/clojisr/v1/r_test.clj @@ -46,9 +46,21 @@ (first (r/r->clj (r/r! true)))))) (deftest bra-colon + (is (= [21.0] + (-> r.datasets/mtcars + (r/r$ "mpg") + (r/brabra 1) + (r/r->clj)))) (is (= [21.0 22.8 21.4] (-> r.datasets/mtcars (r/r$ "mpg") - (r/bra (r/colon 2 4)) - (r/r->clj) - )))) + (r/bra (r/colon 2 4)) + (r/r->clj))))) + +(deftest str-md + (r/println-captured-str r.datasets/mtcars) + (is (= + "```\n'data.frame':\t32 obs. of 11 variables:\n $ mpg : num 21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...\n $ cyl : num 6 6 4 6 8 6 8 4 4 6 ...\n $ disp: num 160 160 108 258 360 ...\n $ hp : num 110 110 93 110 175 105 245 62 95 123 ...\n $ drat: num 3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...\n $ wt : num 2.62 2.88 2.32 3.21 3.44 ...\n $ qsec: num 16.5 17 18.6 19.4 17 ...\n $ vs : num 0 0 1 1 0 1 0 1 1 1 ...\n $ am : num 1 1 1 0 0 0 0 0 0 0 ...\n $ gear: num 4 4 4 3 3 3 3 4 4 4 ...\n $ carb: num 4 4 1 1 2 1 4 2 2 4 ...\n```" + (r/str-md r.datasets/mtcars)))) + + From 016e0bbe3bf098684a22c724abc7335376f6f287 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Tue, 7 May 2024 19:59:25 +0000 Subject: [PATCH 09/19] added test fro bra< --- src/clojisr/v1/r.clj | 1 - test/clojisr/v1/r_test.clj | 27 +++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/clojisr/v1/r.clj b/src/clojisr/v1/r.clj index e1be463..7cac69a 100644 --- a/src/clojisr/v1/r.clj +++ b/src/clojisr/v1/r.clj @@ -161,7 +161,6 @@ (r "function(x) capture.output(str(x))") ) (defn println-captured-str[x] - (def x x) (-> (apply-function (captured-str) diff --git a/test/clojisr/v1/r_test.clj b/test/clojisr/v1/r_test.clj index 909cabc..4bc301e 100644 --- a/test/clojisr/v1/r_test.clj +++ b/test/clojisr/v1/r_test.clj @@ -1,11 +1,11 @@ (ns clojisr.v1.r-test (:require [clojisr.v1.r :as r] - + [tech.v3.dataset :as ds] [clojisr.v1.require :as require-r] [clojure.test :refer [is deftest] :as t])) (require-r/require-r '[datasets]) - +(require-r/require-r '[base]) (def v [1 2 3]) @@ -64,3 +64,26 @@ (r/str-md r.datasets/mtcars)))) + +(deftest brabra<- + (is (= 8 + (-> + (r/brabra<- + (base/matrix (r/colon 1 12)) + 1 8) + r/r->clj + (ds/column 1) + first)))) + +(deftest bra<- + (is (= 8 + (-> + (r/bra<- + (range 5) + 1 8) + r/r->clj + first) + ))) + + + From e0887e231312ec501293e71408afc4a4a0f0a04e Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Tue, 7 May 2024 20:06:15 +0000 Subject: [PATCH 10/19] one more test --- src/clojisr/v1/r.clj | 6 ++---- test/clojisr/v1/r_test.clj | 7 ++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/clojisr/v1/r.clj b/src/clojisr/v1/r.clj index 7cac69a..9d06f98 100644 --- a/src/clojisr/v1/r.clj +++ b/src/clojisr/v1/r.clj @@ -131,13 +131,11 @@ (run! (fn [op] (intern-r-binary (str "r" op) op)) - ["==", "!=" "<" ">" "<=" ">=" "&" "&&" "|" "||" - ;"r!" - "$" "-"]) + ["==", "!=" "<" ">" "<=" ">=" "&" "&&" "|" "||" "$" "-"]) (intern *ns* (symbol "r!") (fn [e] - ((clojisr.v1.r/r "`!`") e))) + ((clojisr.v1.r/r "`!`") e))) ;; (def r== (r "`==`")) diff --git a/test/clojisr/v1/r_test.clj b/test/clojisr/v1/r_test.clj index 4bc301e..9791088 100644 --- a/test/clojisr/v1/r_test.clj +++ b/test/clojisr/v1/r_test.clj @@ -42,8 +42,13 @@ ])))) (deftest unary + + (is (= 9.0 (-> (r/r** 3 2) r/r->clj first))) (is (not - (first (r/r->clj (r/r! true)))))) + (-> (r/r! true) r/r->clj first) + ))) + + (deftest bra-colon (is (= [21.0] From 71dd39dee0095578f323f8e7e05c4e0d774b1c89 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Tue, 7 May 2024 20:15:28 +0000 Subject: [PATCH 11/19] cleaned up --- src/clojisr/v1/r.clj | 51 +++++++++++--------------------------------- 1 file changed, 13 insertions(+), 38 deletions(-) diff --git a/src/clojisr/v1/r.clj b/src/clojisr/v1/r.clj index 9d06f98..ef417b0 100644 --- a/src/clojisr/v1/r.clj +++ b/src/clojisr/v1/r.clj @@ -125,34 +125,10 @@ (intern *ns* ns (r ns))))) (defn- intern-r-binary [clj-op op] - (intern *ns* (symbol clj-op) + (intern *ns* (symbol clj-op) (fn [e1 e2] ((clojisr.v1.r/r (format "`%s`" op)) e1 e2)))) -(run! - (fn [op] (intern-r-binary (str "r" op) op)) - ["==", "!=" "<" ">" "<=" ">=" "&" "&&" "|" "||" "$" "-"]) - -(intern *ns* (symbol "r!") - (fn [e] - ((clojisr.v1.r/r "`!`") e))) - - -;; (def r== (r "`==`")) -;; (def r!= (r "`!=`")) -;; (def r< (r "`<`")) -;; (def r> (r "`>`")) -;; (def r<= (r "`<=`")) -;; (def r>= (r "`>=`")) -;; (def r& (r "`&`")) -;; (def r&& (r "`&&`")) -;; (def r| (r "`||`")) -;; (def r|| (r "`||`")) -;; (def r! (r "`!`")) -;; (def r$ (r "`$`")) - - - (defn- captured-str [] "For the R function [str](https://www.rdocumentation.org/packages/utils/versions/3.6.1/topics/str), we capture the standard output and return the corresponding string." @@ -173,15 +149,6 @@ r-lines->md)) - - -(intern-r-binary "r**" "^") - -;; (def r** (r "`^`")) -(intern-r-binary "rdiv" "/") -;; (def rdiv (r "`/`")) - -;; (def r- (r "`-`")) (defn r* [& args] (reduce (r "`*`") args)) @@ -190,10 +157,7 @@ [& args] (reduce (r "`+`") args)) -;; Some special characters will get a name in letters. -;; (def colon (r "`:`")) -(intern-r-binary "colon" ":") -;; + (defmacro defr "Create Clojure and R bindings at the same time" @@ -262,3 +226,14 @@ ([function package] (println (help function package)))) +(run! + (fn [op] (intern-r-binary (str "r" op) op)) + ["==", "!=" "<" ">" "<=" ">=" "&" "&&" "|" "||" "$" "-"]) + +(intern *ns* (symbol "r!") + (fn [e] + ((clojisr.v1.r/r "`!`") e))) +(intern-r-binary "r**" "^") +(intern-r-binary "rdiv" "/") +;; Some special characters will get a name in letters. +(intern-r-binary "colon" ":") From 44d4d512a1ec61b9f9eba1c6567a05584afe78aa Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Tue, 7 May 2024 20:28:38 +0000 Subject: [PATCH 12/19] replaced bra macro by functions --- src/clojisr/v1/r.clj | 34 ++++++++++++++++++++++++---------- src/clojisr/v1/util.clj | 6 ------ test/clojisr/v1/r_test.clj | 1 + 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/clojisr/v1/r.clj b/src/clojisr/v1/r.clj index ef417b0..c171c9d 100644 --- a/src/clojisr/v1/r.clj +++ b/src/clojisr/v1/r.clj @@ -185,16 +185,30 @@ (prepare-args-for-bra pars) (conj (prepare-args-for-bra (butlast pars)) (last pars))))) -(defmacro ^:private make-bras - [] - `(do ~@(for [[bra-sym-name [bra-str all?]] bracket-data - :let [bra-sym (symbol bra-sym-name)]] - `(let [bra# (r ~bra-str)] - (defn ~bra-sym [& pars#] - (let [fixed# (prepare-args-for-bra pars# ~all?)] - (apply bra# fixed#))))))) - -(make-bras) + +(defn bra [& pars] + (let + [bra (clojisr.v1.r/r "`[`") + fixed (prepare-args-for-bra pars true)] + (clojure.core/apply bra fixed))) + +(defn brabra [& pars] + (let + [bra (clojisr.v1.r/r "`[[`") + fixed (prepare-args-for-bra pars true)] + (clojure.core/apply bra fixed))) + +(defn bra<- [& pars] + (let + [bra (clojisr.v1.r/r "`[<-`") + fixed (prepare-args-for-bra pars false)] + (clojure.core/apply bra fixed))) + +(defn brabra<- [& pars] + (let + [bra (clojisr.v1.r/r "`[[<-`") + fixed (prepare-args-for-bra pars false)] + (clojure.core/apply bra fixed))) diff --git a/src/clojisr/v1/util.clj b/src/clojisr/v1/util.clj index b1cb6ee..1bc518a 100644 --- a/src/clojisr/v1/util.clj +++ b/src/clojisr/v1/util.clj @@ -144,12 +144,6 @@ (.close socket) (.getLocalPort socket))) -;; symbol, string, how to process parameters (all or butlast) -(def bracket-data {"bra" ["`[`" true] - "brabra" ["`[[`" true] - "bra<-" ["`[<-`" false] - "brabra<-" ["`[[<-`" false]}) - (defn maybe-wrap-backtick [string-or-symbol] (if (symbol? string-or-symbol) diff --git a/test/clojisr/v1/r_test.clj b/test/clojisr/v1/r_test.clj index 9791088..3f9c00d 100644 --- a/test/clojisr/v1/r_test.clj +++ b/test/clojisr/v1/r_test.clj @@ -92,3 +92,4 @@ + From ecac1ccf2929c2a587061e79863831282a2d99b8 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Tue, 7 May 2024 21:54:55 +0000 Subject: [PATCH 13/19] re-added bracked-data --- src/clojisr/v1/r.clj | 2 +- src/clojisr/v1/util.clj | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/clojisr/v1/r.clj b/src/clojisr/v1/r.clj index c171c9d..7007307 100644 --- a/src/clojisr/v1/r.clj +++ b/src/clojisr/v1/r.clj @@ -9,7 +9,7 @@ [clojisr.v1.impl.java-to-clj :as java2clj] [clojisr.v1.impl.clj-to-java :as clj2java] [clojure.string :as string] - [clojisr.v1.util :refer [bracket-data maybe-wrap-backtick]] + [clojisr.v1.util :refer [maybe-wrap-backtick]] [clojisr.v1.require :refer [require-r-package]] [clojisr.v1.engines :refer [engines]]) (:import clojisr.v1.robject.RObject)) diff --git a/src/clojisr/v1/util.clj b/src/clojisr/v1/util.clj index 1bc518a..483918a 100644 --- a/src/clojisr/v1/util.clj +++ b/src/clojisr/v1/util.clj @@ -144,6 +144,11 @@ (.close socket) (.getLocalPort socket))) +(def bracket-data {"bra" ["`[`" true] + "brabra" ["`[[`" true] + "bra<-" ["`[<-`" false] + "brabra<-" ["`[[<-`" false]}) + (defn maybe-wrap-backtick [string-or-symbol] (if (symbol? string-or-symbol) From 41dace9afe601f571757303dce4c30b2ec655b94 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Wed, 8 May 2024 14:05:32 +0000 Subject: [PATCH 14/19] comment back --- src/clojisr/v1/util.clj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/clojisr/v1/util.clj b/src/clojisr/v1/util.clj index 483918a..b1cb6ee 100644 --- a/src/clojisr/v1/util.clj +++ b/src/clojisr/v1/util.clj @@ -144,6 +144,7 @@ (.close socket) (.getLocalPort socket))) +;; symbol, string, how to process parameters (all or butlast) (def bracket-data {"bra" ["`[`" true] "brabra" ["`[[`" true] "bra<-" ["`[<-`" false] From 33d8b7e5b3130429ba7e30e6334204b2acb56829 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Wed, 8 May 2024 14:57:14 +0000 Subject: [PATCH 15/19] make all lazy in plotting --- src/clojisr/v1/applications/plotting.clj | 44 ++++++++++--------- .../clojisr/v1/applications/plotting_test.clj | 25 +++++++++++ 2 files changed, 49 insertions(+), 20 deletions(-) create mode 100644 test/clojisr/v1/applications/plotting_test.clj diff --git a/src/clojisr/v1/applications/plotting.clj b/src/clojisr/v1/applications/plotting.clj index 882f6e5..5292380 100644 --- a/src/clojisr/v1/applications/plotting.clj +++ b/src/clojisr/v1/applications/plotting.clj @@ -11,53 +11,57 @@ [java.awt.image BufferedImage] [javax.swing ImageIcon])) -(require-r '[grDevices]) -(def files->fns (atom (let [devices (select-keys (ns-publics 'r.grDevices) '[pdf png svg jpeg tiff bmp])] - (if-let [jpg (get devices 'jpeg)] - (let [devices (assoc devices 'jpg jpg)] - (if (-> '(%in% "svglite" (rownames (installed.packages))) ;; check if svglite is available - (r) - (r->clj) - (first)) - (assoc devices 'svg (rsymbol "svglite" "svglite")) - (do (log/warn [::plotting {:messaage "We highly recommend installing of `svglite` package."}]) - devices))) - devices)))) + + +(def files->fns (delay + (atom (let [_ (require-r '[grDevices]) + devices (select-keys (ns-publics 'r.grDevices) '[pdf png svg jpeg tiff bmp])] + (if-let [jpg (get devices 'jpeg)] + (let [devices (assoc devices 'jpg jpg)] + (if (-> '(%in% "svglite" (rownames (installed.packages))) ;; check if svglite is available + (r) + (r->clj) + (first)) + (assoc devices 'svg (rsymbol "svglite" "svglite")) + (do (log/warn [::plotting {:messaage "We highly recommend installing of `svglite` package."}]) + devices))) + devices))))) (defn use-svg! "Use from now on build-in svg device for plotting svg." [] - (swap! files->fns assoc 'svg (get (ns-publics 'r.grDevices) 'svg))) + (swap! @files->fns assoc 'svg (get (ns-publics 'r.grDevices) 'svg))) (defn use-svglite! "Use from now on svglite device for plotting svg. Requires package `svglite` to be installed" [] - (swap! files->fns assoc 'svg (rsymbol "svglite" "svglite"))) + (swap! @files->fns assoc 'svg (rsymbol "svglite" "svglite"))) + -(def ^:private r-print (r "print")) ;; avoid importing `base` here (defn plot->file [^String filename plotting-function-or-object & device-params] - (let [apath (.getAbsolutePath (File. filename)) + (let [r-print (delay (r "print")) + apath (.getAbsolutePath (File. filename)) extension (symbol (or (second (re-find #"\.(\w+)$" apath)) :no)) - device (@files->fns extension)] - (if-not (contains? @files->fns extension) + device (@@files->fns extension)] + (if-not (contains? @@files->fns extension) (log/warn [::plot->file {:message (format "%s filetype is not supported!" (name extension))}]) (try (make-parents filename) (apply device :filename apath device-params) (let [the-plot-robject (try (if (instance? RObject plotting-function-or-object) - (r-print plotting-function-or-object) + (@r-print plotting-function-or-object) (plotting-function-or-object)) (catch Exception e (log/warn [::plot->file {:message "Evaluation plotting function failed." :exception (exception-cause e)}])) - (finally (r.grDevices/dev-off)))] + (finally (r "grDevices::dev.off()")))] (log/debug [[::plot->file {:message (format "File %s saved." apath)}]]) the-plot-robject) (catch clojure.lang.ExceptionInfo e (throw e)) diff --git a/test/clojisr/v1/applications/plotting_test.clj b/test/clojisr/v1/applications/plotting_test.clj new file mode 100644 index 0000000..dcfe864 --- /dev/null +++ b/test/clojisr/v1/applications/plotting_test.clj @@ -0,0 +1,25 @@ +(ns clojisr.v1.applications.plotting-test + (:require [clojisr.v1.applications.plotting :as plot] + [clojisr.v1.r :as r] + [clojure.string :as str] + [clojure.test :refer [is deftest]])) + +(require '[clojisr.v1.applications.plotting :refer [plot->svg plot->file plot->buffered-image]]) +(r/require-r '[graphics :refer [plot hist]]) + +(deftest plot-svg + (let [svg + (plot->svg + (fn [] + (->> rand + (repeatedly 30) + (reductions +) + (plot :xlab "t" + :ylab "y" + :type "l"))))] + + (is ( true? + (str/includes? + svg + "M 3.8125 -7.96875 C 3.207031 -7.96875 2.75 -7.664062 2.4375 -7.0625"))))) + From c952bed0f66028d1b58b3b84c442b70995ee6895 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Wed, 8 May 2024 15:12:30 +0000 Subject: [PATCH 16/19] made plotting full lazy requiring R --- test/clojisr/v1/applications/plotting_test.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/clojisr/v1/applications/plotting_test.clj b/test/clojisr/v1/applications/plotting_test.clj index dcfe864..a121ae5 100644 --- a/test/clojisr/v1/applications/plotting_test.clj +++ b/test/clojisr/v1/applications/plotting_test.clj @@ -2,9 +2,9 @@ (:require [clojisr.v1.applications.plotting :as plot] [clojisr.v1.r :as r] [clojure.string :as str] + [clojisr.v1.applications.plotting :refer [plot->svg plot->file plot->buffered-image]] [clojure.test :refer [is deftest]])) -(require '[clojisr.v1.applications.plotting :refer [plot->svg plot->file plot->buffered-image]]) (r/require-r '[graphics :refer [plot hist]]) (deftest plot-svg From f46bbfee80bb2ebf3ce9dd2557db351fac3d80b3 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Fri, 10 May 2024 14:30:19 +0000 Subject: [PATCH 17/19] fixed tests on CI --- .devcontainer/Dockerfile | 2 +- deps.edn | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a1d3163..1b60248 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,4 +2,4 @@ FROM mcr.microsoft.com/devcontainers/java:11-bullseye RUN bash -c "bash < <(curl -s https://raw.githubusercontent.com/babashka/babashka/master/install)" RUN bash -c "bash < <(curl -s https://raw.githubusercontent.com/clojure-lsp/clojure-lsp/master/install)" -RUN apt-get update && apt-get install -y rlwrap gfortran libblas-dev liblapack-dev libpng-dev libfontconfig1-dev libfreetype-dev gfortran libicu-dev cmake leiningen +RUN apt-get update && apt-get install -y rlwrap gfortran libblas-dev liblapack-dev libpng-dev libfontconfig1-dev libfreetype-dev gfortran libicu-dev cmake leiningen libxi6 libxtst6 diff --git a/deps.edn b/deps.edn index 9d2129b..47d5110 100644 --- a/deps.edn +++ b/deps.edn @@ -16,4 +16,5 @@ io.github.cognitect-labs/test-runner {:git/tag "v0.5.0" :git/sha "b3fd0d2"}} :main-opts ["-m" "cognitect.test-runner"] + :jvm-opts ["-Djava.awt.headless=true" ] :exec-fn cognitect.test-runner.api/test}}} From 5a711b485a41199535b913ebca80febb8b297ae9 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Fri, 10 May 2024 15:23:55 +0000 Subject: [PATCH 18/19] refactored to defn with docu added `rcolon` for consistency --- src/clojisr/v1/r.clj | 167 ++++++++++++++++++++++++++----------- test/clojisr/v1/r_test.clj | 3 +- 2 files changed, 119 insertions(+), 51 deletions(-) diff --git a/src/clojisr/v1/r.clj b/src/clojisr/v1/r.clj index 7007307..ae7a9da 100644 --- a/src/clojisr/v1/r.clj +++ b/src/clojisr/v1/r.clj @@ -124,11 +124,6 @@ (r (format fmt n (name package))) (intern *ns* ns (r ns))))) -(defn- intern-r-binary [clj-op op] - (intern *ns* (symbol clj-op) - (fn [e1 e2] - ((clojisr.v1.r/r (format "`%s`" op)) e1 e2)))) - (defn- captured-str [] "For the R function [str](https://www.rdocumentation.org/packages/utils/versions/3.6.1/topics/str), we capture the standard output and return the corresponding string." @@ -149,16 +144,6 @@ r-lines->md)) - -(defn r* [& args] (reduce (r "`*`") args)) - -(defn r+ - "The plus operator is a binary one, and we want to use it on an arbitraty number of arguments." - [& args] - (reduce (r "`+`") args)) - - - (defmacro defr "Create Clojure and R bindings at the same time" [name & r] @@ -174,7 +159,7 @@ ([package string-or-symbol] (r (str (maybe-wrap-backtick package) "::" (maybe-wrap-backtick string-or-symbol))))) -;; brackets! + ;; FIXME! Waiting for session management. (defn- prepare-args-for-bra @@ -186,30 +171,6 @@ (conj (prepare-args-for-bra (butlast pars)) (last pars))))) -(defn bra [& pars] - (let - [bra (clojisr.v1.r/r "`[`") - fixed (prepare-args-for-bra pars true)] - (clojure.core/apply bra fixed))) - -(defn brabra [& pars] - (let - [bra (clojisr.v1.r/r "`[[`") - fixed (prepare-args-for-bra pars true)] - (clojure.core/apply bra fixed))) - -(defn bra<- [& pars] - (let - [bra (clojisr.v1.r/r "`[<-`") - fixed (prepare-args-for-bra pars false)] - (clojure.core/apply bra fixed))) - -(defn brabra<- [& pars] - (let - [bra (clojisr.v1.r/r "`[[<-`") - fixed (prepare-args-for-bra pars false)] - (clojure.core/apply bra fixed))) - ;; register shutdown hook @@ -240,14 +201,120 @@ ([function package] (println (help function package)))) -(run! - (fn [op] (intern-r-binary (str "r" op) op)) - ["==", "!=" "<" ">" "<=" ">=" "&" "&&" "|" "||" "$" "-"]) +;; arithmetic operators +(defn r- + "R arithmetic operator `-`" + [e1 e2] ((r "`-`") e1 e2)) + +(defn rdiv + "R arithmetic operator `/`" + [e1 e2] ((r "`/`") e1 e2)) + +(defn r* + "R arithmetic operator `*`, but can be used on an arbitraty number of arguments." + [& args] + (reduce (r "`*`") args)) + +(defn r+ + "R arithmetic operator `+`, but can be used on an arbitraty number of arguments." + [& args] + (reduce (r "`+`") args)) + +(defn r** + "R arithmetic operator `^`" + [e1 e2] + ((r "`^`") e1 e2)) + + +;; relational operators +(defn r== + "R relational operator `==`" + [e1 e2] ( (r "`==`") e1 e2)) + +(defn r!= + "R relational operator `=!`" + [e1 e2] ((r "`!=`") e1 e2)) + +(defn r< + "R relational operator `<`" + [e1 e2] ((r "`<`") e1 e2)) + +(defn r> + "R relational operator `>`" + [e1 e2] ((r "`>`") e1 e2)) + +(defn r<= + "R relational operator `<=`" + [e1 e2] ((r "`<=`") e1 e2)) + +(defn r>= + "R relational operator `>=`" + [e1 e2] ((r "`>=`") e1 e2)) + +;; logical operators +(defn r& + "R logical operator `&`" + [e1 e2] ((r "`&`") e1 e2)) + +(defn r&& + "R logical operator `&&`" + [e1 e2] ((r "`&&`") e1 e2)) + +(defn r| + "R logical operator `|`" + [e1 e2] ((r "`|`") e1 e2)) + +(defn r|| + "R logical operator `||`" + [e1 e2] ((r "`||`") e1 e2)) + +(defn r! + "R logical operator `!`" + [e] ((r "`!`") e)) + +;; colon operators +(defn colon + "R colon operator `:`" + [e1 e2] ((r "`:`") e1 e2)) +(defn rcolon + "R colon operator `:`" + [e1 e2] (colon e1 e2)) + +;; extract/replace operators +(defn r$ + "R extract operator `$`" + [e1 e2] ((r "`$`") e1 e2)) + + +(defn bra + "R extract operator `[`" + [& pars] + (let + [bra (clojisr.v1.r/r "`[`") + fixed (prepare-args-for-bra pars true)] + (clojure.core/apply bra fixed))) + +(defn brabra + "R extract operator `[[`" + [& pars] + (let + [bra (clojisr.v1.r/r "`[[`") + fixed (prepare-args-for-bra pars true)] + (clojure.core/apply bra fixed))) + +(defn bra<- + "R replace operator `[<-`" + [& pars] + (let + [bra (clojisr.v1.r/r "`[<-`") + fixed (prepare-args-for-bra pars false)] + (clojure.core/apply bra fixed))) + +(defn brabra<- + "R replace operator `[[<-`" + [& pars] + (let + [bra (clojisr.v1.r/r "`[[<-`") + fixed (prepare-args-for-bra pars false)] + (clojure.core/apply bra fixed))) -(intern *ns* (symbol "r!") - (fn [e] - ((clojisr.v1.r/r "`!`") e))) -(intern-r-binary "r**" "^") -(intern-r-binary "rdiv" "/") -;; Some special characters will get a name in letters. -(intern-r-binary "colon" ":") diff --git a/test/clojisr/v1/r_test.clj b/test/clojisr/v1/r_test.clj index 3f9c00d..b1b6977 100644 --- a/test/clojisr/v1/r_test.clj +++ b/test/clojisr/v1/r_test.clj @@ -18,7 +18,7 @@ (deftest binaries - (is (= [true false false false true true true true true true 0 2 1 1.0 1] + (is (= [true false false false true true true true true true 0 2 1 1.0 1 1] (map (fn [f] @@ -39,6 +39,7 @@ r/r* r/rdiv r/colon + r/rcolon ])))) (deftest unary From 7118fc25f9bb9ae3f55964ff560d705a63f485e8 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Sun, 12 May 2024 19:39:42 +0000 Subject: [PATCH 19/19] aaded misisng operators --- .devcontainer/Dockerfile | 2 +- CHANGELOG.md | 2 ++ src/clojisr/v1/r.clj | 22 +++++++++++++++++++++- test/clojisr/v1/r_test.clj | 9 +++++++-- 4 files changed, 31 insertions(+), 4 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 1b60248..97f695e 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/devcontainers/java:11-bullseye +FROM mcr.microsoft.com/devcontainers/java:21-bookworm RUN bash -c "bash < <(curl -s https://raw.githubusercontent.com/babashka/babashka/master/install)" RUN bash -c "bash < <(curl -s https://raw.githubusercontent.com/clojure-lsp/clojure-lsp/master/install)" diff --git a/CHANGELOG.md b/CHANGELOG.md index f7f3dd4..c9d2b2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Change Log All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). +## unreleased +- added more operators `%/%`, `%%` ,`%in%`, `xor` ## [1.0.0] - `require-r` creates namespace as `r.namespace`, also `namespace` as an alias - dependencies update, TMD 7.029 diff --git a/src/clojisr/v1/r.clj b/src/clojisr/v1/r.clj index ae7a9da..8319459 100644 --- a/src/clojisr/v1/r.clj +++ b/src/clojisr/v1/r.clj @@ -225,6 +225,15 @@ [e1 e2] ((r "`^`") e1 e2)) +(defn r%div% + "R arithmetic operator `%/%`" + [e1 e2] + ((r "`%/%`") e1 e2)) + +(defn r%% + "R arithmetic operator `%%`" + [e1 e2] + ((r "`%%`") e1 e2)) ;; relational operators (defn r== @@ -268,10 +277,15 @@ "R logical operator `||`" [e1 e2] ((r "`||`") e1 e2)) -(defn r! +(defn r! "R logical operator `!`" [e] ((r "`!`") e)) +(defn rxor + "R logical operator `xor`" + [e1 e2] ((r "`xor`") e1 e2)) + + ;; colon operators (defn colon "R colon operator `:`" @@ -286,6 +300,12 @@ [e1 e2] ((r "`$`") e1 e2)) +(defn r%in% + "R match operator `%in%`" + [e1 e2] ((r "`%in%`") e1 e2)) + + + (defn bra "R extract operator `[`" [& pars] diff --git a/test/clojisr/v1/r_test.clj b/test/clojisr/v1/r_test.clj index b1b6977..e734b53 100644 --- a/test/clojisr/v1/r_test.clj +++ b/test/clojisr/v1/r_test.clj @@ -18,9 +18,9 @@ (deftest binaries - (is (= [true false false false true true true true true true 0 2 1 1.0 1 1] + (is (= [true false false false true true true true true true 0 2 1 1.0 1 1 1 0 false true] - (map + (mapv (fn [f] (first (r/r->clj (f 1 1)))) @@ -40,8 +40,13 @@ r/rdiv r/colon r/rcolon + r/r%div% + r/r%% + r/rxor + r/r%in% ])))) + (deftest unary (is (= 9.0 (-> (r/r** 3 2) r/r->clj first)))