diff --git a/src/main/java/org/math/R/R2js/AbstractR2jsSession.java b/src/main/java/org/math/R/AbstractR2jsSession.java similarity index 99% rename from src/main/java/org/math/R/R2js/AbstractR2jsSession.java rename to src/main/java/org/math/R/AbstractR2jsSession.java index 318ae0ae..78add0c3 100644 --- a/src/main/java/org/math/R/R2js/AbstractR2jsSession.java +++ b/src/main/java/org/math/R/AbstractR2jsSession.java @@ -1,4 +1,4 @@ -package org.math.R.R2js; +package org.math.R; import java.io.BufferedReader; import java.io.File; @@ -13,7 +13,6 @@ import java.util.stream.Collectors; import org.apache.commons.io.FileUtils; -import org.math.R.*; /** * This class evaluate an R expression by parsing it in javascript expression diff --git a/src/main/java/org/math/R/R2js/R2jsSession.java b/src/main/java/org/math/R/R2jsSession.java similarity index 99% rename from src/main/java/org/math/R/R2js/R2jsSession.java rename to src/main/java/org/math/R/R2jsSession.java index 56a91e83..43ddd328 100644 --- a/src/main/java/org/math/R/R2js/R2jsSession.java +++ b/src/main/java/org/math/R/R2jsSession.java @@ -1,8 +1,4 @@ -package org.math.R.R2js; - -import org.math.R.RLog; -import org.math.R.RLogPrintStream; -import org.math.R.Rsession; +package org.math.R; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; diff --git a/src/main/java/org/math/R/R2js/R2jsUtils.java b/src/main/java/org/math/R/R2jsUtils.java similarity index 99% rename from src/main/java/org/math/R/R2js/R2jsUtils.java rename to src/main/java/org/math/R/R2jsUtils.java index ef916e28..9aee6eeb 100644 --- a/src/main/java/org/math/R/R2js/R2jsUtils.java +++ b/src/main/java/org/math/R/R2jsUtils.java @@ -3,7 +3,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -package org.math.R.R2js; +package org.math.R; import java.util.ArrayList; import java.util.List; diff --git a/src/main/resources/org/math/R/R.js b/src/main/resources/org/math/R/R.js index c655a7c5..e249f8d7 100644 --- a/src/main/resources/org/math/R/R.js +++ b/src/main/resources/org/math/R/R.js @@ -558,12 +558,12 @@ function SysSetEnv(kv) { for(var k in kv) { - Java.type('org.math.R.R2js.AbstractR2jsSession').setEnv(k,kv[k]); + Java.type('org.math.R.AbstractR2jsSession').setEnv(k,kv[k]); } } function SysGetEnv(k) { - var v = Java.type('org.math.R.R2js.AbstractR2jsSession').getEnv(k); + var v = Java.type('org.math.R.AbstractR2jsSession').getEnv(k); if (isNull(v)) return ''; return v; diff --git a/src/test/java/org/math/R/BasicTest.java b/src/test/java/org/math/R/BasicTest.java index ebaa806c..77b9ad0e 100644 --- a/src/test/java/org/math/R/BasicTest.java +++ b/src/test/java/org/math/R/BasicTest.java @@ -9,8 +9,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.math.R.R2js.AbstractR2jsSession; -import org.math.R.R2js.R2jsSession; /** * diff --git a/src/test/java/org/math/R/BrentTest.java b/src/test/java/org/math/R/BrentTest.java index 9b01a326..d686db7e 100644 --- a/src/test/java/org/math/R/BrentTest.java +++ b/src/test/java/org/math/R/BrentTest.java @@ -7,8 +7,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.math.R.R2js.R2jsSession; -import org.math.R.R2js.AbstractR2jsSession; import org.math.array.DoubleArray; import org.math.array.LinearAlgebra; diff --git a/src/test/java/org/math/R/GradientDescent1DTest.java b/src/test/java/org/math/R/GradientDescent1DTest.java index df7ede1f..6be16eee 100644 --- a/src/test/java/org/math/R/GradientDescent1DTest.java +++ b/src/test/java/org/math/R/GradientDescent1DTest.java @@ -7,8 +7,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.math.R.R2js.AbstractR2jsSession; -import org.math.R.R2js.R2jsSession; import org.math.R.Rsession.RException; import org.math.array.DoubleArray; diff --git a/src/test/java/org/math/R/GradientDescentTest.java b/src/test/java/org/math/R/GradientDescentTest.java index a4e05909..483ac362 100644 --- a/src/test/java/org/math/R/GradientDescentTest.java +++ b/src/test/java/org/math/R/GradientDescentTest.java @@ -6,8 +6,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.math.R.R2js.AbstractR2jsSession; -import org.math.R.R2js.R2jsSession; import org.math.R.Rsession.RException; import org.math.array.DoubleArray; diff --git a/src/test/java/org/math/R/R2js/R2jsParserTest.java b/src/test/java/org/math/R/R2jsParserTest.java similarity index 98% rename from src/test/java/org/math/R/R2js/R2jsParserTest.java rename to src/test/java/org/math/R/R2jsParserTest.java index aa20bd47..3212c95f 100644 --- a/src/test/java/org/math/R/R2js/R2jsParserTest.java +++ b/src/test/java/org/math/R/R2jsParserTest.java @@ -1,8 +1,10 @@ -package org.math.R.R2js; +package org.math.R; import java.util.Arrays; import java.util.List; import org.junit.Test; +import org.math.R.AbstractR2jsSession; +import org.math.R.R2jsUtils; import org.math.R.Rsession; /** diff --git a/src/test/java/org/math/R/R2js/R2jsSessionTest.java b/src/test/java/org/math/R/R2jsSessionTest.java similarity index 94% rename from src/test/java/org/math/R/R2js/R2jsSessionTest.java rename to src/test/java/org/math/R/R2jsSessionTest.java index 017ad1d7..df0ac0a3 100644 --- a/src/test/java/org/math/R/R2js/R2jsSessionTest.java +++ b/src/test/java/org/math/R/R2jsSessionTest.java @@ -1,4 +1,4 @@ -package org.math.R.R2js; +package org.math.R; import java.io.*; import java.net.InetAddress; @@ -16,8 +16,6 @@ //import org.graalvm.polyglot.*; import org.junit.Test; -import org.math.R.RLog; -import org.math.R.RLogSlf4j; import org.math.R.Rsession.RException; import static org.junit.Assert.*; @@ -1484,87 +1482,4 @@ public void testDecimalPoints() throws RException { assert (Double) engine.eval("1e-31+1e-32") == 1.1e-31; assertEquals((Double) engine.eval("1e-31*1e-32"), 1e-63, 1e-75); //"normal" floating error of 1e-15 on multiplication } - -// @Test -// public void testEvaluationTime() throws RException, ScriptException, IOException { -// String MATH_JS_FILE = "/org/math/R/math.js"; -// InputStream mathInputStream = this.getClass().getResourceAsStream(MATH_JS_FILE); -//// -//// -//// StringBuilder textBuilder = new StringBuilder(); -//// try (Reader reader = new BufferedReader(new InputStreamReader -//// (mathInputStream, StandardCharsets.UTF_8))) { -//// int c = 0; -//// while ((c = reader.read()) != -1) { -//// textBuilder.append((char) c); -//// } -//// } -//// -//// Context polyglotContext = Context.create(); -// -//// -//// //polyglotContext.eval("js", textBuilder); -// -// -// // POLYGLOT -//// long time1 = System.currentTimeMillis(); -//// Source scriptSource = Source.newBuilder("js",new File("/home/chabs/Documents/workspaces/rsession/src/main/resources/org/math/R/math.js")).build(); -//// Engine engine = Engine.create(); -//// Context ctx = Context.newBuilder() -//// .engine(engine) -//// .build(); -//// long time2 = System.currentTimeMillis(); -//// -//// Value result = ctx.eval(scriptSource); -//// //Value math = ctx.getBindings("js").getMember("math"); -//// System.out.println("Res=" + ctx.eval("js", "math.add(1,2)")); -//// -//// long time3 = System.currentTimeMillis(); -//// -//// //Context newContext = Context.newBuilder("js").(true).option("js.foreign-object-prototype", Boolean.TRUE.toString()).build(); -//// Context newContext = Context.newBuilder() -//// .engine(engine) -//// .build(); -//// newContext.eval(scriptSource); -//// //newContext.getBindings("js").putMember("math", math); -//// -//// System.out.println("Res=" + newContext.eval("js", "math.add(1,11)")); -//// -//// long time4 = System.currentTimeMillis(); -//// -//// System.out.println("Evaluation time polyglot:" + (time2 - time1) + " ms"); -//// System.out.println("Evaluation time polyglot:" + (time3 - time2) + " ms"); -//// System.out.println("Evaluation time polyglot:" + (time4 - time3) + " ms"); -// -// -// -// long time1 = System.currentTimeMillis(); -// ScriptEngineManager manager = new ScriptEngineManager(null); -// long time11 = System.currentTimeMillis(); -// ScriptEngine js = manager.getEngineByName("JavaScript"); -// if (js==null) js = manager.getEngineByName("js"); -// if (js==null) js = manager.getEngineByExtension("js"); -// if (js==null) js = manager.getEngineByName("nashorn"); -// if (js==null) js = manager.getEngineByName("Nashorn"); -// //if (js==null) js = new jdk.nashorn.api.scripting.NashornScriptEngineFactory().getScriptEngine(); -// if (js==null) throw new IllegalArgumentException("Could not load JavaScript ScriptEngine: "+manager.getEngineFactories()); -// -// long time2 = System.currentTimeMillis(); -// js.eval(new InputStreamReader(mathInputStream, Charset.forName("UTF-8"))); -// System.out.println("Res="+ js.eval("math.add(1,2)")); -// Object math = js.get("math"); -// long time3 = System.currentTimeMillis(); -// ScriptEngine js2 = manager.getEngineByName("JavaScript"); -// //System.out.println("Res="+ js2.eval("math.add(1,11)")); -// js2.put("math", math); -// System.out.println("Res="+ js2.eval("math.add(1,11)")); -// long time4 = System.currentTimeMillis(); -// -// System.out.println("Evaluation time polyglot---:" + (time11 - time1) + " ms"); -// System.out.println("Evaluation time polyglot:" + (time2 - time1) + " ms"); -// System.out.println("Evaluation time polyglot:" + (time3 - time2) + " ms"); -// System.out.println("Evaluation time polyglot:" + (time4 - time3) + " ms"); -// -// } - } diff --git a/src/test/java/org/math/R/RPanelsTest.java b/src/test/java/org/math/R/RPanelsTest.java index 9b2b06ae..8d40921f 100644 --- a/src/test/java/org/math/R/RPanelsTest.java +++ b/src/test/java/org/math/R/RPanelsTest.java @@ -10,8 +10,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.math.R.R2js.AbstractR2jsSession; -import org.math.R.R2js.R2jsSession; import org.math.R.Rsession.RException; /**