Using Python from Analytica
New in Analytica 7.0
Requires the Analytica Developer edition.
Introduction
- Short overview
- use cases, motivation
Setting up a Python environment
- Very brief basics.
conda create -n MyEnv python=3.11- Configuring Python Environment or Model Environment sysvars in Analytica.
- Link to Setting up a Python environment for detailed info.
Importing Python modules and objects
- The Python Startup Code sysvar
- Use of "From module Import object"
The Python namespace
- The py:: namespace prefix
- The arrow -> operator
Calling a Python function
- py::F(...) calling syntax
- PyEval, and treatment of locals
Using Python code in Definitions
- The Python Expression view for definitions
- Writing an Analytica UDF with python code in body
- Using "def" or "class" in python code.
- The Callable
Dependencies
- The convenience of Analytica's dependencies.
- Drawing arrows to indicate dependence where Python doesn't track it.
Non-scalar data structures
- Distinction between Python data structures and Analytica data structures. How Python objects display in «...»
- Why to sometimes keep as python data structure w/o exploding
= Converting from Python data to Analytica
- Automatic conversions (including list of types)
- PyExplode
- Basic usage. Nested usage.
- Include/exclude types
- Collections: np.array, dict, set/map, pandas data frame (documented on a separate library page), etc.
Converting from Analytica to Python data structures
- Automatic conversions (including a list of the types)
- PyList, PySet, PyArray, ...
Comments
Enable comment auto-refresher