You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pycode/memilio-generation/memilio/tools/README.md
+17-22Lines changed: 17 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,25 +18,25 @@ Before running the example script, configure the following settings:
18
18
`conf.target_folder`: Defines the folder where the generated Python file will be stored.
19
19
20
20
21
-
Example Configuration:
22
-
If you want to use the ode_secirvvs model the config should be like this -> `conf.source_file = os.path.abspath(os.path.join(file_path, "..", "..", "..", "..", "cpp", "models", "ode_secirvvs", "model.cpp"))`
21
+
Example Configuration:<br>
22
+
If you want to use the ode_secirvvs model the config should be like this:<br> `conf.source_file = os.path.abspath(os.path.join(file_path, "..", "..", "..", "..", "cpp", "models", "ode_secirvvs", "model.cpp"))`<br>
23
23
This descibes the filepath to your model.cpp outgoing from the tools folder.
24
24
25
25
To use a different model, replace ode_secirvvs with the desired model's name in the file path.
26
26
27
-
Adding Additional Source Files:
27
+
Adding Additional Source Files:<br>
28
28
In addition to the main source file, it is possible to include further source files in the binding process.
29
-
For this purpose, the `asts´ instance of the [ASTHandler class](/pycode/memilio-generation/memilio/generation/ast_handler.py) provides the method `add_source_file´:
30
-
```python
31
-
asts.add_source_file("name_of_the_file.cpp")
32
-
```
29
+
For this purpose, the `asts` instance of the [ASTHandler class](/pycode/memilio-generation/memilio/generation/ast_handler.py) provides the method `add_source_file`:<br>
30
+
Example:<br>
31
+
`asts.add_source_file("name_of_the_file.cpp")`
32
+
33
33
34
-
To set up a target folder, specify the desired output directory for the generated bindings here:
35
-
`conf.target_folder = file_path`
36
-
If no custom path is specified and `file_path`is used as the target folder, the generated files will be saved in
34
+
To set up a target folder, specify the desired output directory for the generated bindings here:<br>
35
+
`conf.target_folder = file_path`<br>
36
+
If no custom path is specified and `file_path`is used as the target folder, the generated files will be saved in
37
37
the tools directory by default, as this is the working directory of the skript.
38
38
39
-
After setting up the source file and target folder, set the path to the example script in the terminal:
39
+
After setting up the source files and target folder, set the path to the example script in the terminal.<br>
40
40
If the terminal shows the memilio package, just give the path with:
41
41
```bash
42
42
cd pycode/memilio-generation/memilio/tools
@@ -50,7 +50,7 @@ python example_oseir.py
50
50
51
51
## Visualization
52
52
53
-
The package contains a [Visualization class](/pycode/memilio-generation/memilio/generation/graph_visualization.py) to display the generated AST.
53
+
The package contains a [Visualization class](/pycode/memilio-generation/memilio/generation/graph_visualization.py) to display the generated AST.<br>
54
54
This allows for:
55
55
56
56
- Printing the AST in the terminal
@@ -59,29 +59,24 @@ This allows for:
59
59
60
60
- Formatting it in a text file
61
61
62
-
You can print the AST in the example script with the aviz instance of the Visualisation() class.
62
+
You can print the AST in the example script with the `aviz` instance of the Visualisation() class.
63
63
64
64
65
-
Example:
66
-
`aviz.output_ast_formatted(asts.get_ast_by_id(0), ast.get_node_by_index(1))` displays the second node of the first AST and its children in a file called ast_formatted.txt.
65
+
Example:<br>
66
+
`aviz.output_ast_formatted(asts.get_ast_by_id(0), ast.get_node_by_index(1))`displays the second node of the first AST and its children in a file called ast_formatted.txt.<br>
67
67
The root node `.get_node_by_index(0)` displays the whole AST.
68
68
69
69
`aviz.output_ast_terminal(asts.get_ast_by_id(0), ast.get_node_by_index(1))` displays the second node of the AST and its children in terminal.
70
70
71
-
The first argument of the statements specify the given AST. The second argument specifies the node and its children that you want to display.
71
+
The first argument of the statements specifies the selected AST. The second argument specifies the node and its children that you want to display.
72
72
73
73
`aviz.output_ast_png(ast.get_node_by_index(2), 2)` displays the third node of the AST and its children with a depth of 2 as a png file. The second argument of the statement specifies the depth up to which the function displays child nodes. This means that any nodes beyond the specified depth (e.g., all nodes at level 3 and beyond if the depth is set to 2) will not be shown.
74
74
The output of the AST as a PNG should be restricted, since not many nodes can be displayed at once in a PNG. So only subtrees with a restricted depth should be printed.
75
75
76
-
The visualization is specified under the `if (print_ast):` statement in the example script.
76
+
The visualization is specified under the `if (print_ast):` statement in the example script. There you can choose which of the display methods you want to output.<br>
77
77
It is enabled when running the example with the following command:
0 commit comments