Skip to content

Latest commit

 

History

History
69 lines (48 loc) · 2.22 KB

python_builder.rst

File metadata and controls

69 lines (48 loc) · 2.22 KB

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 characters. 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:


Supported expressions examples

Operators

Functions

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: