The DDA module

(The following documentation is about the module itself and not very useful in the moment)

PyDDA is a small library to write and generate DDA code in Python. DDA stands for digital differential analyzer. In this context, it is a code for solving ordinary differential equations given in a domain specific language description (i.e. an electrical circuit).

For further details, please see the doc/ directory (Sphinx documentation).

dda.export(state, to, **kw)[source]

Convenience function to export (transform) a state to some other programming language.

Possible formats (allowed values for to) supported so far are:

This function shall be nice, so it accepts many spelling/notation of these language names.

The return value are typically strings or tuples, dicts. There should be no side effects.

dda.clean(thing, target='C')[source]

Cleans an identifier for being compatible with the target language. This can be something like C, python or dda (cf. languages supported by dda.export()) or also latex.

It will basically try to transliterate all Unicode to ASCII and then try to ensure that the identifier is a valid C variable name (i.e. don’t start with numbers, etc.).

This function is nice, if you pass a dda.State or dda.Symbol, it will map the whole State/Symbol. Otherwise, it expects a string.

Examples:

>>> clean("\frac{x}{y}")  # backslashes are just removed   
'fracxy'
>>> clean(r'a^{-1}')
'a__1'
>>> clean('a^b_c^{ef}')
'a_b_c_ef'
>>> clean(u'µ²')   # only if python package "unidecode" is installed 
'u2'
>>> clean('77%alc')   # well, you can use numbers at the beginning of strings
'_77alc'