aiida.common.ipython package

Submodules

An IPython extension that provides a magic command to load basic aiida commands.

This makes it much easier to start.

Produces output in:

  • Plaintext (IPython [qt]console)
  • HTML (IPython notebook, nbconvert --to html, --to slides)
  • JSON (IPython notebook .ipynb files)
  • LaTeX (e.g. ipython nbconvert example.ipynb --to LaTeX --post PDF)

Notes on how to load it at start: https://ipython.org/ipython-doc/3/config/intro.html

Usage

In [1]: %load_ext aiida_magic

In [2]: %aiida
class aiida.common.ipython.ipython_magics.AiiDALoaderMagics(shell=None, **kwargs)[source]

Bases: IPython.core.magic.Magics

__module__ = 'aiida.common.ipython.ipython_magics'
_repr_html_()[source]

Output in HTML format.

_repr_json_()[source]

Output in JSON format.

_repr_latex_()[source]

Output in LaTeX format.

_repr_pretty_(pp, cycle)[source]

Output in text format.

_trait_default_generators = {}
aiida(line='', local_ns=None)[source]

Load AiiDA in ipython (checking if it was already loaded), and inserts in the namespace the main AiiDA classes (the same that are loaded in verdi shell.

Usage:

%aiida [optional parameters]

Todo

implement parameters, e.g. for the profile to load.

magics = {'cell': {}, 'line': {'aiida': 'aiida'}}
registered = True
aiida.common.ipython.ipython_magics.add_to_ns(local_ns, name, obj)[source]

Add a new variable with name name and value obj to the namespace local_ns, optionally showing a warning if we are hiding an existing variable.

Todo

implement the warning.

Example:

# assuming that local_ns is a dictionary, e.g. from locals()
import sys
add_to_ns(local_ns, 'sys', sys)
aiida.common.ipython.ipython_magics.load_ipython_extension(ipython)[source]

Triggers the load of all the AiiDA magic commands.