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.
.. automodule:: pysd.builders.python.python_model_builder :members:
.. automodule:: pysd.builders.python.python_expressions_builder :members:
.. automodule:: pysd.builders.python.namespace :members: NamespaceManager
.. automodule:: pysd.builders.python.subscripts :members:
.. automodule:: pysd.builders.python.imports :members: