JFriCAS¶
jfricas.spad line 87 [edit on github]
The JFriCAS package contains functions to start a webserver and to initialize ioHooks for the communication between FriCAS and the Jupyter frontend. It also manages the communication between FriCAS (via the Hunchentoot webserver) and the Jupyter notebook.
- addLinks: XHashTable(String, String) -> String -> String
addLinks(ht)(type) returns a string that for every constructorcthat appears as a string in the keys ofhta link to the online API constructor documentation ofc.
- extendConstructorURLs: (XHashTable(String, String), String) -> XHashTable(String, String)
extendConstructorURLs(h,url)creates a copy ofhwhere each constructor name that is not yet existing inhgets an entry with valueurl.
- fricaskernel: () -> Void
fricaskernel()writes out a file fricaskernel.py to the current directory. This file should be installed together kernel.json (generated by the kernel() function call) in your jupyter/python environment.
- handleOutput: (Boolean, String) -> String
handleOutput(err?, out)translates the output out into a string that contains a JSON structure that is to be understood by fricaskernel.py. The function interprets the “–FORMAT:BEG:”/”–FORMAT:END:” pairs, in particular reads off the step number from their end and groups the output into substructures indexed by the step number of FriCAS. The JSON record looks like {“error?”:true, “souts”: [s1,…,sn]} where ‘error?’ is either True or False (depending on whether or not the evaluation produced an error) and the responsessiare dictionaries that represent stepped outputs,i.eare of the form {“step”: step, “outs”: [o1, …, om]} and theoiare of the form {content_type: content}. Note that content_type can be “ERROR”, which means that the respective content is an error message or is content that was outside ofe“–FORMAT:BEG:”/”–FORMAT:END:” pair.
- initialize: () -> Void
initialize()defines a number of functions for jFriCAS to work.
- jfricasIOHandler: (Symbol, SExpression) -> Void
jfricasIOHandler(s)reacts on certain ioHooks and writes out begin and end markers to stdout so that the corresponding fricaskernel.py can single out the various kinds of messages that comes from FriCAS.
- kernel: () -> Void
kernel()writes out a file kernel.json to the current directory. This file should be installed together fricaskernel.py (generated by the fricaskernel() function call) in your jupyter/python environment.
- setTranslateType!: (String -> String) -> String -> String
setTranslateType!(fun)sets the functionfunthat is used inhandleOutputto translate the type returnd by FriCAS into something more pleasing to the user. A good candidate forfunisaddLinks(h)for a respective hashtable constructed viaextendConstructorURLs.
- start: NonNegativeInteger -> Boolean
start(p)initializes jFriCAS and starts a new webserver instance on portp. It returnstrueif successful andfalseif the hunchentoot webserver is not available.