diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3cc0f57..bd1b099c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,17 +16,23 @@ jobs: strategy: fail-fast: false matrix: - java: [ '8', '11', '16', '17', '19' ] + java: [ '8', '11', '16', '17', '19', '21' ] runs-on: [ubuntu-latest, macos-latest, windows-latest] + exclude: + - runs-on: macos-latest + java: "8" + - runs-on: macos-latest + java: "16" + name: Test on Java ${{ matrix.Java }} on ${{ matrix.runs-on }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up JDK ${{ matrix.Java }} - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: java-version: ${{ matrix.Java }} - distribution: 'adopt' + distribution: 'temurin' - name: Test with Maven run: mvn install - name: Further tests, non Win diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 347719ff..14fb26ba 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: nelonoel/branch-name@v1.0.1 # https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions @@ -20,7 +20,7 @@ jobs: id: extract_branch - name: Checkout lems - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: repository: LEMS/LEMS ref: ${{ steps.extract_branch.outputs.branch }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cf2282a5..00000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -dist: xenial - -language: java - -jdk: - - oraclejdk11 - - - openjdk8 - #- openjdk10 # Some non deterministic recurring error with jdk10... - - openjdk11 - -install: - - mvn install - -script: - - pwd - - ./lems src/test/resources/example1.xml -nogui - - ./lems src/test/resources/example2.xml -nogui - - ./lems src/test/resources/example3.xml -nogui - - ./lems src/test/resources/example4.xml -nogui - - ./lems src/test/resources/example5.xml -nogui - - ./lems src/test/resources/example6.xml -nogui - - ./lems src/test/resources/example7.xml -nogui - - ./lems src/test/resources/example8.xml -nogui - - ./lems src/test/resources/bounce-conditional.xml -nogui - - ./lems src/test/resources/bounce.xml -nogui - - ./lems src/test/resources/ex-flat.xml -nogui - - ./lems src/test/resources/test_regime_iaf.xml -nogui - - ./lems src/test/resources/ex-properties.xml -nogui - diff --git a/build.xml b/build.xml index 9764b5e2..1ee5272b 100644 --- a/build.xml +++ b/build.xml @@ -42,8 +42,8 @@ diff --git a/lems b/lems index c869991b..0f77317a 100755 --- a/lems +++ b/lems @@ -1,6 +1,6 @@ #!/bin/sh -export LEMS_VERSION=0.10.8 +export LEMS_VERSION=0.11.1 export CLASSPATH=.:./target/jlems-$LEMS_VERSION.jar:$LEMS_HOME/target/jlems-$LEMS_VERSION.jar diff --git a/lems.bat b/lems.bat index 4f4c86af..2789bf9b 100644 --- a/lems.bat +++ b/lems.bat @@ -1,6 +1,6 @@ @echo off -set LEMS_VERSION=0.10.8 +set LEMS_VERSION=0.11.1 set CLASSPATH=target\jlems-%LEMS_VERSION%.jar;%LEMS_HOME%\target\jlems-%LEMS_VERSION%.jar diff --git a/pom.xml b/pom.xml index 9ce7c27a..e76407fe 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.lemsml jlems - 0.10.8 + 0.11.1 bundle UTF-8 @@ -29,8 +29,8 @@ maven-compiler-plugin 3.0 - 1.7 - 1.7 + 1.8 + 1.8 diff --git a/src/main/java/org/lemsml/jlems/core/run/StateInstance.java b/src/main/java/org/lemsml/jlems/core/run/StateInstance.java index 7595e156..a87ef92e 100644 --- a/src/main/java/org/lemsml/jlems/core/run/StateInstance.java +++ b/src/main/java/org/lemsml/jlems/core/run/StateInstance.java @@ -300,6 +300,9 @@ public void advance(StateRunnable parent, double t, double dt) throws RuntimeErr public void transitionTo(String rnm) throws RuntimeError { + if (regimeHM == null) { + throw new IllegalStateException("No Regimes."); + } activeRegime = regimeHM.get(rnm); activeRegime.enter(); } @@ -314,6 +317,9 @@ public void doneInit() { public void initRegime() throws RuntimeError { if (activeRegime == null) { + if (regimeHM == null || regimeHM.isEmpty()) { + throw new IllegalStateException("No Regimes."); + } activeRegime = regimeHM.get(regimeHM.keySet().iterator().next()); // TODO just picks random regime } diff --git a/src/main/java/org/lemsml/jlems/core/type/dynamics/AbstractStateChange.java b/src/main/java/org/lemsml/jlems/core/type/dynamics/AbstractStateChange.java index 566f0b9c..b3f16e08 100644 --- a/src/main/java/org/lemsml/jlems/core/type/dynamics/AbstractStateChange.java +++ b/src/main/java/org/lemsml/jlems/core/type/dynamics/AbstractStateChange.java @@ -90,9 +90,12 @@ public void checkDimensions(HashMap dimHM) throws ContentEr if (dres.isDimensionless()) { // OK } else { - E.oneLineError("Dimension mismatch in equation: " + variable + " = " + value + ". Residual dimension: " + dres); - E.info("Dimension of " + variable + ": " + dsv + ", multiplier=" + dlf + ", left=" + dl + ", rhs=" + drhs); - E.info("All:" + dimHM); + + String errmsg = ("Dimension mismatch in the equation: " + variable + " = " + value + ". Residual dimension: " + dres + + "\nDimension of " + variable + ": " + dsv + ", multiplier=" + dlf + ", left=" + dl + ", rhs=" + drhs + + "\nAll:" + dimHM); + E.info(errmsg); + throw new ContentError(errmsg); } } diff --git a/src/main/java/org/lemsml/jlems/core/type/dynamics/Dynamics.java b/src/main/java/org/lemsml/jlems/core/type/dynamics/Dynamics.java index 61fb70f4..a982c2fe 100644 --- a/src/main/java/org/lemsml/jlems/core/type/dynamics/Dynamics.java +++ b/src/main/java/org/lemsml/jlems/core/type/dynamics/Dynamics.java @@ -525,7 +525,7 @@ public Valued getValued(String select) throws ContentError { - public void checkEquations(HashMap cdimHM) throws ContentError { + public void checkEquations(HashMap cdimHM) throws ContentError{ HashMap dimHM = new HashMap(); @@ -559,7 +559,9 @@ public void checkEquations(HashMap cdimHM) throws ContentEr try { dimHM.put(dv.getName(), dv.getDimensionality(dimHM)); } catch (ContentError ce) { - E.error("Checking " + dv + " in " + r_type + " " + ce.getMessage()); + String errmsg = ("Checking derived variable: " + dv + " in " + r_type + "\nError here: " + ce.getMessage()); + E.error(errmsg+"\n**************\n* Note: this may not be a serious error, in the case that the derived variables are all present, just have been specified out of order, e.g. b = f(a) is defined in the xML file before a is defined. "); + } } @@ -567,7 +569,8 @@ public void checkEquations(HashMap cdimHM) throws ContentEr try { dimHM.put(cdv.getName(), cdv.getDimensionality(dimHM)); } catch (ContentError ce) { - E.error("Checking " + cdv + " in " + r_type + " " + ce.getMessage()); + String errmsg = "Checking " + cdv + " in " + r_type + " " + ce.getMessage(); + throw new ContentError(errmsg); } } diff --git a/src/main/java/org/lemsml/jlems/io/Main.java b/src/main/java/org/lemsml/jlems/io/Main.java index 034fad2d..169f31e2 100644 --- a/src/main/java/org/lemsml/jlems/io/Main.java +++ b/src/main/java/org/lemsml/jlems/io/Main.java @@ -19,7 +19,7 @@ public final class Main { - public static final String VERSION = "0.10.8"; + public static final String VERSION = "0.11.1"; static String usage = "USAGE: java -jar target/jlems-"+VERSION+".jar [-cp folderpaths] model-file [-nogui]\n"; diff --git a/src/test/java/org/lemsml/jlems/test/ExamplesTest.java b/src/test/java/org/lemsml/jlems/test/ExamplesTest.java index 20acd6e7..f2ac725d 100644 --- a/src/test/java/org/lemsml/jlems/test/ExamplesTest.java +++ b/src/test/java/org/lemsml/jlems/test/ExamplesTest.java @@ -85,6 +85,7 @@ public void testExample10() throws ContentError, ConnectionError, RuntimeError, public boolean executeExample(String filename) throws ContentError, ConnectionError, RuntimeError, ParseError, IOException, ParseException, BuildException, XMLException { URL url = this.getClass().getResource("/"+filename); + System.out.println(" - Testing: "+url); File f = new File(url.getFile()); FileInclusionReader fir = new FileInclusionReader(f); diff --git a/src/test/java/org/lemsml/jlems/test/XMLExamplesReaderTest.java b/src/test/java/org/lemsml/jlems/test/XMLExamplesReaderTest.java index b478511e..17ecd114 100644 --- a/src/test/java/org/lemsml/jlems/test/XMLExamplesReaderTest.java +++ b/src/test/java/org/lemsml/jlems/test/XMLExamplesReaderTest.java @@ -29,7 +29,7 @@ public void testReadFromString() throws ParseException, BuildException, File fdir = new File(url.getFile()); for (File fx : fdir.listFiles()) { - E.info("Testing: " + fx); + E.info(" >>> Testing: " + fx); if (fx.isFile() && fx.getName().endsWith(".xml")) { String stxt = FileUtil.readStringFromFile(fx); XMLElementReader xmlReader = new XMLElementReader(stxt); @@ -53,7 +53,7 @@ public void testReadFromString() throws ParseException, BuildException, + "'' and not ''"); } - assertEquals("Rewrite matches", sns.length(), tns.length()); + assertEquals("Rewrite matches ("+fx+")", sns.length(), tns.length()); } } } diff --git a/src/test/resources/SimpleNetwork.xml b/src/test/resources/SimpleNetwork.xml index 507842a0..9a55a87d 100644 --- a/src/test/resources/SimpleNetwork.xml +++ b/src/test/resources/SimpleNetwork.xml @@ -4,7 +4,6 @@ - @@ -13,8 +12,6 @@ - - @@ -23,17 +20,13 @@ - - - + - - diff --git a/src/test/resources/SingleSimulation.xml b/src/test/resources/SingleSimulation.xml index 1a2319da..e6a7d555 100644 --- a/src/test/resources/SingleSimulation.xml +++ b/src/test/resources/SingleSimulation.xml @@ -1,22 +1,17 @@ - - - + - - - @@ -27,20 +22,15 @@ - - - - - @@ -48,28 +38,17 @@ - - - - - - - - - - - - \ No newline at end of file + diff --git a/src/test/resources/elecdims.xml b/src/test/resources/elecdims.xml index c81221a4..612f2cf3 100644 --- a/src/test/resources/elecdims.xml +++ b/src/test/resources/elecdims.xml @@ -4,5 +4,4 @@ - - \ No newline at end of file + diff --git a/src/test/resources/ex2dims.xml b/src/test/resources/ex2dims.xml index aeb1e228..702c3194 100644 --- a/src/test/resources/ex2dims.xml +++ b/src/test/resources/ex2dims.xml @@ -1,5 +1,4 @@ - - + @@ -8,8 +7,8 @@ - - + + @@ -19,5 +18,4 @@ - - \ No newline at end of file + diff --git a/src/test/resources/example1.xml b/src/test/resources/example1.xml index d84c23b6..393f3f8c 100644 --- a/src/test/resources/example1.xml +++ b/src/test/resources/example1.xml @@ -1,275 +1,220 @@ + - - - - - - - - - + + + + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + - - + - + - - - - - - - + + + + + - - - + + - + - - - - - + + + - - + + - - + + - - - + + - - + + - - - - - - + + + + + - - + - - + - - - + + - - - - - - + + + + + - - - - - + + + + + - - - - - - + + + + + - - - - - - - + + + + + + + - - - - + + + - - + + - - - + + - - + + - - - + + - - - - - - - + + + + + - - - + + + - - + - - - - - - - + + + + + - + - - - - + + + - - - - + + - - - - - - - - - - - - - - + + + + + - - - - - - + + + + - + - - - - + - - - - + + + + - - \ No newline at end of file + diff --git a/src/test/resources/example2.xml b/src/test/resources/example2.xml index bdfe1b42..26e39531 100644 --- a/src/test/resources/example2.xml +++ b/src/test/resources/example2.xml @@ -1,51 +1,40 @@ - - + - - + - - + - - + - - - + - - - - - - + + + - - - + + + - - \ No newline at end of file + diff --git a/src/test/resources/example3.xml b/src/test/resources/example3.xml index 7e78b8b8..bbee903c 100644 --- a/src/test/resources/example3.xml +++ b/src/test/resources/example3.xml @@ -1,21 +1,13 @@ - - - + - - - - - + - @@ -23,98 +15,75 @@ - - - - - + + - - - - - + - - - - + - - - - - + - - - - + - - - - - - + + @@ -123,7 +92,4 @@ - - - - \ No newline at end of file + diff --git a/src/test/resources/example4.xml b/src/test/resources/example4.xml index d905399c..74660f4e 100644 --- a/src/test/resources/example4.xml +++ b/src/test/resources/example4.xml @@ -1,46 +1,35 @@ - - - + - - - - - - + - - @@ -51,12 +40,10 @@ - - @@ -64,7 +51,6 @@ - @@ -72,8 +58,7 @@ - - + @@ -82,53 +67,42 @@ - - - - - + + + - - + - - - - - - - - + + + - - - @@ -139,24 +113,19 @@ - - + - - - - - - + + @@ -165,15 +134,11 @@ - - - - - \ No newline at end of file + diff --git a/src/test/resources/example5.xml b/src/test/resources/example5.xml index c574a42b..38aa9562 100644 --- a/src/test/resources/example5.xml +++ b/src/test/resources/example5.xml @@ -1,5 +1,4 @@ - @@ -9,12 +8,10 @@ - - @@ -24,50 +21,39 @@ - - + - - - - - - - - + + - - @@ -78,21 +64,17 @@ - - - - @@ -100,8 +82,7 @@ - - + @@ -110,35 +91,26 @@ - - - - - - - - + + + - - + - - - @@ -146,21 +118,15 @@ - - - - - - + + + - - - @@ -172,27 +138,22 @@ - - + - - - - - + + - - \ No newline at end of file + diff --git a/src/test/resources/example6.xml b/src/test/resources/example6.xml index 8dd4025b..12e3f6d4 100644 --- a/src/test/resources/example6.xml +++ b/src/test/resources/example6.xml @@ -1,44 +1,35 @@ - - - + + - - + - - - + - - + - + - - - @@ -49,25 +40,19 @@ - - - - - - - + @@ -75,6 +60,4 @@ --> - - - \ No newline at end of file + diff --git a/src/test/resources/example7.xml b/src/test/resources/example7.xml index 4e46e4cb..89c6311e 100644 --- a/src/test/resources/example7.xml +++ b/src/test/resources/example7.xml @@ -1,76 +1,59 @@ - - - - + + - - - - - + - - - - - - - + - - + - - - - \ No newline at end of file + diff --git a/src/test/resources/example8.xml b/src/test/resources/example8.xml index 43d0b54e..b7dbc6f9 100644 --- a/src/test/resources/example8.xml +++ b/src/test/resources/example8.xml @@ -1,119 +1,95 @@ - - - - + - - - - - - - - - + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - - - - - + - - + - - - - + - - - - + @@ -121,6 +97,4 @@ - - - \ No newline at end of file + diff --git a/src/test/resources/hhaltgate.xml b/src/test/resources/hhaltgate.xml index 39906ee0..64c3f8d2 100644 --- a/src/test/resources/hhaltgate.xml +++ b/src/test/resources/hhaltgate.xml @@ -1,24 +1,18 @@ - - + - - - - + - - + - - \ No newline at end of file + diff --git a/src/test/resources/hhcell.xml b/src/test/resources/hhcell.xml index 90575e19..782f2991 100644 --- a/src/test/resources/hhcell.xml +++ b/src/test/resources/hhcell.xml @@ -1,12 +1,9 @@ - - - @@ -14,36 +11,29 @@ - - - - - - - + - - \ No newline at end of file + diff --git a/src/test/resources/hhchannel.xml b/src/test/resources/hhchannel.xml index 7e7c6b47..debc1cbf 100644 --- a/src/test/resources/hhchannel.xml +++ b/src/test/resources/hhchannel.xml @@ -1,5 +1,4 @@ - @@ -7,7 +6,6 @@ - @@ -16,49 +14,42 @@ - - + - - - - + - - + - + - - @@ -68,7 +59,4 @@ - - - diff --git a/src/test/resources/hhmodels.xml b/src/test/resources/hhmodels.xml index 60c36859..770bbe9e 100644 --- a/src/test/resources/hhmodels.xml +++ b/src/test/resources/hhmodels.xml @@ -1,29 +1,25 @@ - + - - - - - \ No newline at end of file + diff --git a/src/test/resources/misciaf.xml b/src/test/resources/misciaf.xml index 6899caee..10ea7f24 100644 --- a/src/test/resources/misciaf.xml +++ b/src/test/resources/misciaf.xml @@ -1,7 +1,5 @@ - - @@ -9,24 +7,18 @@ - - - - + - - - - \ No newline at end of file + diff --git a/src/test/resources/spikegenerators.xml b/src/test/resources/spikegenerators.xml index dd8db3f6..6c0d8dae 100644 --- a/src/test/resources/spikegenerators.xml +++ b/src/test/resources/spikegenerators.xml @@ -1,7 +1,5 @@ - - @@ -17,7 +15,6 @@ - @@ -28,6 +25,4 @@ - - - \ No newline at end of file +