Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
7a8d3b3
Initial cookiecutter labextension
LuckyJollyJumper Mar 20, 2023
1440924
Added panel widget
LuckyJollyJumper Mar 20, 2023
2a0a0ac
Tried adding button in notebook menu
LuckyJollyJumper Mar 21, 2023
17e1b0f
Started over again, working button
LuckyJollyJumper Mar 28, 2023
efa8fa7
Fixed some sentences
LuckyJollyJumper Mar 28, 2023
c0d88e9
Added command
LuckyJollyJumper Mar 28, 2023
dc6bcce
Stable version
LuckyJollyJumper Mar 31, 2023
c83c741
icon.ts linking fixed, added widget
LuckyJollyJumper Apr 2, 2023
651a7c9
Cleaned up code and remove 14 errors
LuckyJollyJumper Apr 14, 2023
edd6068
Removed double imports
LuckyJollyJumper Apr 19, 2023
3e4a3a5
Added react widget and panel
LuckyJollyJumper Apr 19, 2023
5fb44ca
Started kernel messaging
LuckyJollyJumper Apr 19, 2023
024cf75
Added comment
LuckyJollyJumper Apr 19, 2023
6c49e9b
Added @jupyterlab/translation and /launcher
LuckyJollyJumper Apr 19, 2023
79d8927
Tried to connect panel to notebookmenu
LuckyJollyJumper Apr 19, 2023
716bc7d
Fixed wrong spacing
LuckyJollyJumper Apr 19, 2023
2daba42
Small consistency fix
LuckyJollyJumper May 18, 2023
d815e2b
Added %plot to magics
LuckyJollyJumper May 18, 2023
adc5bc7
typo
LuckyJollyJumper May 18, 2023
17b4cf8
Added write_png_to_stdout
LuckyJollyJumper May 20, 2023
dbf55b2
Graphs as output to Jupyter working
LuckyJollyJumper May 20, 2023
84e9ca3
%plot can take arguments
LuckyJollyJumper May 20, 2023
957fc33
All magics work again
LuckyJollyJumper May 20, 2023
cc79ac2
Statement support 1
LuckyJollyJumper May 20, 2023
4bc7864
Better error handling
LuckyJollyJumper May 23, 2023
4b73d76
Reshuffled some code
LuckyJollyJumper May 23, 2023
6e32799
Extracted sac expr part from d_execute()
LuckyJollyJumper May 23, 2023
b81a60a
Long overdue push
LuckyJollyJumper Oct 30, 2023
8317ea6
Added old sac2c import
LuckyJollyJumper Oct 30, 2023
0d4f3e3
Merge remote-tracking branch 'origin' into graphs
LuckyJollyJumper Oct 30, 2023
37dca30
Reformat after merge
LuckyJollyJumper Oct 30, 2023
7b1428d
Improved structure of PLotaction
LuckyJollyJumper Oct 30, 2023
89fcf70
Merge with main
LuckyJollyJumper Oct 30, 2023
384e9b3
Converted all the stderr and stdin calls
LuckyJollyJumper Oct 30, 2023
ca26545
First attempt at outputting plot
LuckyJollyJumper Oct 30, 2023
cf75664
Able to output plots in Jupyter
LuckyJollyJumper Oct 30, 2023
5305394
Reformat and added variables evaluation
LuckyJollyJumper Oct 31, 2023
f546c11
Minor changes
LuckyJollyJumper Nov 7, 2023
2c9409f
Added pyPrint.sac
LuckyJollyJumper Dec 5, 2023
9c92546
Fixed sac func bug
LuckyJollyJumper Dec 5, 2023
67e26f3
Added pyPrint sac function
LuckyJollyJumper Dec 5, 2023
a95d9b3
Fixed bug in func Action
LuckyJollyJumper Dec 11, 2023
d687983
Added Python module
LuckyJollyJumper Dec 11, 2023
b387e65
Merge branch 'SacBase:master' into master
LuckyJollyJumper Dec 11, 2023
ef03931
Small fixes
LuckyJollyJumper Dec 11, 2023
80532ed
Merge branch 'master' of github.com:LuckyJollyJumper/sac-jupyter-labe…
LuckyJollyJumper Dec 11, 2023
d4df0bf
Small fixes and cleanup
LuckyJollyJumper Jan 10, 2024
509cf61
Added info about the plot magic
LuckyJollyJumper Jan 10, 2024
14367b7
Fixed incorrect output type
LuckyJollyJumper Jan 10, 2024
9db1553
Final cleanup
LuckyJollyJumper Jan 14, 2024
f3da6bd
Removed unfinished labextension
LuckyJollyJumper Jan 14, 2024
2a5d431
Removed artifact from previous versions
LuckyJollyJumper Jan 15, 2024
ef0aa2c
Added module install information
LuckyJollyJumper Jan 15, 2024
bf0cb42
Added because of the README
LuckyJollyJumper Jan 15, 2024
fc14fed
Added plot info to help action
LuckyJollyJumper Jan 15, 2024
0c0070b
Cleaned up comments
LuckyJollyJumper Jan 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions Python/Python.sac
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
module Python;

provide all;
export all;

use StdIO: all;
use Array: all;

/*
* Module to print sac arrays in python format.
* Works for all SaC datatypes.
*/


void pyPrint(byte[*] a) { pyPrint(toll(a)); }
void pyPrint(short[*] a) { pyPrint(toll(a)); }
void pyPrint(int[*] a) { pyPrint(toll(a)); }
void pyPrint(long[*] a) { pyPrint(toll(a)); }

void pyPrint(ubyte[*] a) { pyPrint(toull(a)); }
void pyPrint(ushort[*] a) { pyPrint(toull(a)); }
void pyPrint(uint[*] a) { pyPrint(toull(a)); }
void pyPrint(ulong[*] a) { pyPrint(toull(a)); }

void pyPrint(float[*] a) { pyPrint(tod(a)); }


void pyPrint (longlong[*] a){
StdIO::printf ("[");

for(i=0; i< shape(a)[0]; i++) {
pyPrint (a[i]);
if (i<shape(a)[0]-1)
StdIO::printf(", ");

}
StdIO::printf ("]");
}
void pyPrint (longlong a){
StdIO::printf ("%d ", a);
}


void pyPrint (ulonglong[*] a){
StdIO::printf ("[");

for(i=0; i< shape(a)[0]; i++) {
pyPrint (a[i]);
if (i<shape(a)[0]-1)
StdIO::printf(", ");

}
StdIO::printf ("]");
}
void pyPrint (ulonglong a){
StdIO::printf ("%d ", a);
}


void pyPrint (double[*] a){
StdIO::printf ("[");

for( i=0; i< shape(a)[0]; i++) {
pyPrint (a[i]);
if (i<shape(a)[0]-1)
StdIO::printf(", ");

}
StdIO::printf ("]");
}
void pyPrint (double a){
StdIO::printf ("%f ", a);
}


void pyPrint (char[*] a){
StdIO::printf ("[");

for(i=0; i< shape(a)[0]; i++) {
pyPrint (a[i]);
if (i<shape(a)[0]-1)
StdIO::printf(", ");

}
StdIO::printf ("]");
}
void pyPrint (char a){
StdIO::printf ("%s ", a);
}
Binary file added Python/host/seq/libPythonMod.so
Binary file not shown.
7 changes: 7 additions & 0 deletions Python/sac2crc.python
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
target Python:

TREE_OUTPUTDIR += ":/home/.../Python"
LIB_OUTPUTDIR += ":/home/.../Python"
LIBS += " "

target package :: Python:
Binary file added Python/tree/host/libPythonTree.so
Binary file not shown.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ Running sac kernel is as simple as:
```bash
jupyter notebook
```
or
```bash
jupyter-lab
```
and in the web interface you set the kernel language to SaC.

On the terminal you can run:
Expand All @@ -53,3 +57,17 @@ ipython console --kernel=sac
If you do so you may want to install this lexer https://github.com/SacBase/sac-pygments
to get syntax highlighting.

## Additional installations
The following module and plotting library need to be installed to be able to use the `%plot` command inside of Jupyter that (as the name suggests) can plot SaC variables inside the notebook. The kernel will still be usable without these additions and is only needed for the plotting feature.

- The [matplotlib](https://matplotlib.org/stable/) python library should be installed on your system for the plots to work. This can be done using the `pip` or third party `conda` library using
```bash
pip install matplotlib
```
or
```bash
conda install matplotlib
```

- The SaC `Python` module present in this repository is also needed for the plot function to work. It needs to be recognised by the SaC library. To do so create a folder called `.sac2crc` in your home directory and paste the file called `sac2crc.python` (found in the Python folder in this repository) into it. The SaC compiler will look for this folder. Edit line 3 and 4 in this file, making them both hold the path to where the `Python` folder is located on your device. Now only the `use Python: all;` statement is needed in the notebook to start plotting.

Loading