Python examples - 5.2 English - 68552

AOCL API Guide (68552)

Document ID
68552
Release Date
2025-12-29
Version
5.2 English

The AOCL-DA Python API comes with numerous example scripts, which are installed when you invoke pip install aoclda-*.whl. To locate these examples, the following commands can be used in your Python interpreter:

>>> from aoclda.examples import info
>>> info.examples_path()
>>> info.examples_list()

Alternatively, from your command prompt, you can call aocl.examples.info as a module to obtain the same information:

python -m aoclda.examples.info

The examples can then be run as standard Python scripts from the command prompt. For example:

python path/to/examples/pca_ex.py

You can also inspect and run the examples from a Python interpreter. For example:

>>> from aoclda.examples import pca_ex
>>> import inspect
>>> print(''.join(inspect.getsourcelines(pca_ex)[0]))
>>> pca_ex.pca_example()