-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b68c503
Showing
12 changed files
with
526 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,60 @@ | ||
name: Java CI | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
tags: [ 'v*.*' ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macOS-latest] | ||
java: [ 8 ] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-java@v1 | ||
with: | ||
java-version: ${{ matrix.java }} | ||
java-package: jdk | ||
- run: | | ||
WD=$PWD | ||
cd .. | ||
git clone https://github.com/Funz/funz-profile | ||
cd $WD | ||
shell: bash | ||
- run: ant -noinput -buildfile build.xml test | ||
|
||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-java@v1 | ||
with: | ||
java-version: 1.8 | ||
java-package: jdk | ||
- run: | | ||
WD=$PWD | ||
cd .. | ||
git clone https://github.com/Funz/funz-profile | ||
cd $WD | ||
- run: | | ||
ant clean dist | ||
cd dist; zip -r ../plugin-Jupyter.zip *; cd .. | ||
ant install | ||
zip -r Funz-Jupyter.zip Funz-Jupyter | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
path: dist | ||
- uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: ./*-Jupyter.zip | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
|
||
|
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,182 @@ | ||
[![.github/workflows/ant.yml](https://github.com/Funz/plugin-Jupyter/actions/workflows/ant.yml/badge.svg)](https://github.com/Funz/plugin-Jupyter/actions/workflows/ant.yml) | ||
|
||
# Funz plugin: Jupyter | ||
|
||
This plugin is dedicated to launch Jupyter calculations from Funz. | ||
It supports the following syntax and features: | ||
|
||
* Input | ||
* file type supported: '*.ipynb', any other format for resources | ||
* parameter syntax: | ||
* variable syntax: `?[...]` | ||
* formula syntax: `${...}` | ||
* comment char: `#` | ||
* example input file: | ||
``` | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [{ | ||
"def branin(x1,x2):\n", | ||
" x1 = x1*15-5\n", | ||
" x2 = x2*15\n", | ||
"\n", | ||
" return (x2 - 5/(4*m.pi**2)*(x1**2) + 5/m.pi*x1 -6 )**2 + 10*(1-1/(8*m.pi))*m.cos(x1) +10" | ||
] | ||
}, | ||
{ | ||
"cell_type": "raw", | ||
"metadata": {}, | ||
"source": [ | ||
"then, eval branin:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"print('z={0}'.format( branin( ?[x1~[1,2]] , ${?[x2] +1.23} ) ) )" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} | ||
``` | ||
* will identify input: | ||
* x1, expected to vary inside [1,2] | ||
* x2, expected to vary inside [0,1] (by default) | ||
* replace `${?[x2] + 1.23}` expression by its evaluation | ||
|
||
* Output | ||
* file type supported: '*.ipynb' | ||
* read any named value printed with `=`, like `print("z={0}".format(1.234))` | ||
* example output file: | ||
``` | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Branin in jupyter" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": { | ||
"execution": { | ||
"iopub.execute_input": "2022-01-07T13:37:11.375854Z", | ||
"iopub.status.busy": "2022-01-07T13:37:11.374259Z", | ||
"iopub.status.idle": "2022-01-07T13:37:11.395234Z", | ||
"shell.execute_reply": "2022-01-07T13:37:11.392893Z" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import math as m\n", | ||
"def branin(x1,x2):\n", | ||
" x1 = x1*15-5\n", | ||
" x2 = x2*15\n", | ||
"\n", | ||
" return (x2 - 5/(4*m.pi**2)*(x1**2) + 5/m.pi*x1 -6 )**2 + 10*(1-1/(8*m.pi))*m.cos(x1) +10" | ||
] | ||
}, | ||
{ | ||
"cell_type": "raw", | ||
"metadata": {}, | ||
"source": [ | ||
"then, eval branin:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": { | ||
"execution": { | ||
"iopub.execute_input": "2022-01-07T13:37:11.405704Z", | ||
"iopub.status.busy": "2022-01-07T13:37:11.404308Z", | ||
"iopub.status.idle": "2022-01-07T13:37:11.411921Z", | ||
"shell.execute_reply": "2022-01-07T13:37:11.413079Z" | ||
} | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"z=3.000715003051446\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"print('z={0}'.format( branin( 0.5, 0.132) ) )" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} | ||
``` | ||
* will return output: | ||
* z=3.000715 | ||
|
||
|
||
![Analytics](https://ga-beacon.appspot.com/UA-109580-20/plugin-Jupyter) |
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,18 @@ | ||
<project name="plugin-Jupyter" default="test" basedir="."> | ||
|
||
<property name="code.name" value="Jupyter" /> | ||
<property name="install.dir" value="${basedir}/Funz-${code.name}" /> | ||
|
||
<property name="build_plugin.xml" location="../funz-profile/build_plugin.xml" /> | ||
<import file="${build_plugin.xml}"/> | ||
|
||
<target name="dist" depends="dist-ioplugin"/> <!-- dist-ioplugin: copy just the plugin ascii files --> | ||
|
||
<target name="test" depends="test-ioplugin"/> <!-- test-ioplugin: test the plugin ascii files --> | ||
|
||
<target name="install" depends="install-plugin"/> <!-- test-ioplugin: test the plugin ascii files --> | ||
|
||
<target name="super.clean" depends="clean"/> | ||
<target name="super.run-reference-cases" depends="run-reference-cases"/> | ||
|
||
</project> |
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 @@ | ||
variableStartSymbol=? | ||
variableLimit=[...] | ||
formulaStartSymbol=$ | ||
formulaLimit={...} | ||
commentLineChar=# | ||
|
||
|
||
outputlist=`grep("(.*)ipynb","print\\(\'(.*)=")>>before("=")>>after("'")` | ||
|
||
output.???.get=lines("(.*)ipynb")>>filter("^(\\s+).???=(.*)")>>after("=")>>replace("\\n","") |
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,77 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Branin in jupyter" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import math as m\n", | ||
"def branin(x1,x2):\n", | ||
" x1 = x1*15-5\n", | ||
" x2 = x2*15\n", | ||
"\n", | ||
" return (x2 - 5/(4*m.pi**2)*(x1**2) + 5/m.pi*x1 -6 )**2 + 10*(1-1/(8*m.pi))*m.cos(x1) +10" | ||
] | ||
}, | ||
{ | ||
"cell_type": "raw", | ||
"metadata": {}, | ||
"source": [ | ||
"then, eval branin:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"z=3.000715003051446\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"print('z={0}'.format( branin( 0.5, 0.132) ) )" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
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 @@ | ||
@echo off | ||
|
||
jupyter nbconvert --execute --to notebook --inplace %*% |
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 @@ | ||
#!/bin/bash | ||
|
||
jupyter nbconvert --execute --to notebook --inplace $* |
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 @@ | ||
#Fri Jan 07 14:59:09 CET 2022 | ||
duration=0 | ||
output={z\=3.000715003051446"} | ||
code=Jupyter | ||
output.z=3.000715003051446" | ||
input.No\ name=No value | ||
start=14\:59\:06 | ||
end= | ||
state=done | ||
calc=localhost\:40855 | ||
info=Results parsed\: {path\=, 1\=1.0, z\=3.000715003051446"} |
Oops, something went wrong.