/
python_builder.rst
69 lines (48 loc) · 2.22 KB
/
python_builder.rst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Python builder
==============
The Python builder allows to build models that can be run with the PySD Model class.
The use of a one-to-one dictionary in translation means that the breadth of functionality is inherently limited. In the case where no direct Python equivalent is available, PySD provides a library of functions such as `pulse`, `step`, etc. that are specific to dynamic model behavior.
In addition to translating individual commands between Vensim/XMILE and Python, PySD reworks component identifiers to be Python-safe by replacing spaces with underscores. The translator allows source identifiers to make use of alphanumeric characters, spaces, or special characteres. In order to make that possible a namespace is created, which links the original name of the variable with the Python-safe name. The namespace is also available in the PySD model class to allow users working with both original names and Python-safe names.
The resulting Python code from building the model is formatted with :py:mod:`black` library and it is written to the same folder where the original model is.
Main builders
-------------
.. automodule:: pysd.builders.python.python_model_builder
:members:
Expression builders
-------------------
.. automodule:: pysd.builders.python.python_expressions_builder
:members:
.. _Python supported functions:
Supported expressions examples
------------------------------
Operators
^^^^^^^^^
.. csv-table:: Supported unary operators
:file: ../tables/unary_python.csv
:header-rows: 1
.. csv-table:: Supported binary operators
:file: ../tables/binary_python.csv
:header-rows: 1
Functions
^^^^^^^^^
.. csv-table:: Supported basic functions
:file: ../tables/functions_python.csv
:header-rows: 1
.. csv-table:: Supported delay functions
:file: ../tables/delay_functions_python.csv
:header-rows: 1
.. csv-table:: Supported get functions
:file: ../tables/get_functions_python.csv
:header-rows: 1
Namespace manager
-----------------
.. automodule:: pysd.builders.python.namespace
:members: NamespaceManager
Subscript manager
-----------------
.. automodule:: pysd.builders.python.subscripts
:members:
Imports manager
---------------
.. automodule:: pysd.builders.python.imports
:members: