2. Utilites

2.1. GNA tools

GNA contains a set of helper tools to simplify calling C++ functions from python. The Constructors module contain wrappers for often used C++ classes’ enabling the user to pass numpy arrays and python lists. The following code converts the python list of strings to std::vector<std::string>:

1import gna.constructors as C
2vec = C.stdvector( ['str1', 'str2', 'str3'] )
3print(vec, list(vec))

The code produces the following output:

1{ "str1", "str2", "str3" } ['str1', 'str2', 'str3']

GNA introduces convenience pythonic methods for its types that may be loaded as follows:

from gna.bindings import common

They include the methods for printing and plotting with matplotlib.

2.2. Tutorial functions

We will use the function tutorial_image_name() to generate the proper names for output images. The names will be printed to the output. The function call may be replaced by a simple string.

2.3. Tutorial options

The tutorial may be executed in batch mode that disables GUI windows. In order to enable it use --batch command line option:

./macro/tutorial/plotting/04_points_plot.py --batch

The batch mode will be triggered automatically in case $DISPLAY environment variable is not set.