Previous Up Next
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

4 Python/Jypyter integration and exports

Interaction with GUI has definite advantages in many cases. Yet we may want occasionally benefit from other tools or export results of our work to different formats.

4.1 Integration with Python and Jupyter notebooks

The present package has several different frontends, e.g. C++ library, Python wrapper and GUI. Recently cloud computing options have been added:

They allow to work with the MoebInv library within the comfortable Jupyter environment without a need of any software installation (besides of recent Web browser).

Coding approach has obvious advantages and a user may want to exchange figures back and forth between Jupyter and GUI. GiNaC Gar archives are universal and robust tools for exchange of data between various GiNaC tools. However, those archives are not directly readable or editable by humans.

Starting from the version v3.5.0 MoebInv is able to convert figures into commented Python scripts. The next method writes such script to a file:

F.write_python_script("my-figure-script.py")

This provides bidirectional integration between the Jupyter and GUI:

Furthermore, to use such code as Jupyter notebook I recommend to post-process the generated Python script with p2j (Python to Jupyter) utility.

4.2 Export a figure to other formats

Besides the lossless translation of a figure to Python script there are the following possibilities to export the figure:

  1. Text file which will briefly encode the list of all cycles with their relations. This text file is similar to the information seen on the tree view panel of GUI.
  2. Bitmap graphics in PNG/JPEG format of the current graphic view. Although bitmap graphics is not of the highest quality and cannot be re-touched later this export instantly produces a portable graphics files ready to use.
  3. Asymptote script, which can be edited and processed by Asymptote [2]. This allows us to produce high quality graphics in PostScript/PDF formats (as well as many raster bitmap formats). Editing the script a user can fine-tune positions of cycle labels or drawing styles. However to use this a working installation of Asymptote is required.

Previous Up Next