Skip to content

Commit 63dcb3a

Browse files
Merge pull request #1645 from virtualcell/AddPythonExpressionSyntax
Add python expression syntax
2 parents 89a4d14 + e79926b commit 63dcb3a

23 files changed

+1012
-251
lines changed

.github/workflows/ci_cd.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ jobs:
8585
java -version
8686
mvn --batch-mode clean install dependency:copy-dependencies -DskipTests=true
8787
88+
- name: Add jython
89+
shell: bash
90+
run: |
91+
curl https://repo1.maven.org/maven2/org/python/jython-installer/2.7.4/jython-installer-2.7.4.jar -o jython-installer.jar
92+
mkdir .temp_holding
93+
mv /home/runner/.m2/repository/org/python/jython/2.7.4/* .temp_holding
94+
java -jar jython-installer.jar -s -d /home/runner/.m2/repository/org/python/jython/2.7.4
95+
8896
- name: Test building of docker image
8997
run: |
9098
docker build \
@@ -170,6 +178,14 @@ jobs:
170178
java-version: '17'
171179
cache: 'maven'
172180

181+
- name: Add jython
182+
shell: bash
183+
run: |
184+
curl https://repo1.maven.org/maven2/org/python/jython-installer/2.7.4/jython-installer-2.7.4.jar -o jython-installer.jar
185+
mkdir .temp_holding
186+
mv /home/runner/.m2/repository/org/python/jython/2.7.4/* .temp_holding
187+
java -jar jython-installer.jar -s -d /home/runner/.m2/repository/org/python/jython/2.7.4
188+
173189
- name: Maven Build and run Test group ${{ matrix.test-group }}
174190
shell: bash
175191
run: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ ziptool
2828
vcell-client/UserDocumentation/originalXML/helpSearchConfig.txt
2929
*.iml
3030
.metadata/
31+
.jython_cache
3132

3233
### Eclipse ###
3334
.metadata

vcell-math/pom.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@
121121
</exclusion>
122122
</exclusions>
123123
</dependency>
124+
<dependency>
125+
<groupId>org.python</groupId>
126+
<artifactId>jython</artifactId>
127+
<version>2.7.4</version>
128+
<scope>compile</scope>
129+
</dependency>
130+
<dependency>
131+
<groupId>org.apache.commons</groupId>
132+
<artifactId>commons-math4-core</artifactId>
133+
<version>4.0-beta1</version>
134+
<scope>compile</scope>
135+
</dependency>
124136
<dependency>
125137
<groupId>org.eclipse.microprofile.openapi</groupId>
126138
<artifactId>microprofile-openapi-api</artifactId>

vcell-math/src/main/java/cbit/vcell/parser/ASTAndNode.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public boolean isBoolean() {
3131
return true;
3232
}
3333

34+
public boolean isLogical() {
35+
return true;
36+
}
37+
3438
public void bind(SymbolTable symbolTable) throws ExpressionBindingException
3539
{
3640
super.bind(symbolTable);
@@ -167,6 +171,13 @@ public String infixString(int lang)
167171
buffer.append(jjtGetChild(i).infixString(lang));
168172
buffer.append(")");
169173
}
174+
}else if(lang == LANGUAGE_PYTHON){
175+
buffer.append("float(bool(");
176+
for (int i=0;i<jjtGetNumChildren();i++){
177+
if (i>0) buffer.append(" and ");
178+
buffer.append(jjtGetChild(i).infixString(lang));
179+
}
180+
buffer.append("))");
170181
}else{
171182
for (int i=0;i<jjtGetNumChildren();i++){
172183
if (i>0) {

vcell-math/src/main/java/cbit/vcell/parser/ASTFloatNode.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ public String infixString(int lang)
142142
return "("+ value +")";
143143
}
144144
}
145-
} else {
145+
} else if (lang == LANGUAGE_PYTHON) {
146+
if (value == Double.POSITIVE_INFINITY) return "float('inf')";
147+
if (value == Double.NEGATIVE_INFINITY) return "float('-inf')";
148+
return value.toString();
149+
} else {
146150
return value.toString();
147151
}
148152
}

0 commit comments

Comments
 (0)