Wiki

Clone wiki

scl-manips-group / nengo / Utils

Implementation and Usage Notes

File: utils.py

Currently consists of three functions.

def getTransposeTransform(m,n)

Let A be an m by n matrix. Let the vector a = ravel(A) be a row-major flattened version of this matrix. Then this function returns an m*n by m*n matrix T, such that Ta = ravel(A').

def replace(text, pairs)

For easy replacing of multiple items. 'pairs' is a list of tuples where the second item in the tuple is to replace the first.

def mathematicaToPython(mathematica_text,mathematica_variable,python_variable,format='raw input')

Reformatting of Mathematica text to be interpreted by Python. This is function is tailored specifically to input that will be seen in the Jacobian or mass matrix of articulated bodies. Variable names in Mathematica may either be subscripted or end with an identifying number. The arguments are detailed below:

  • mathematica_text - text to be reformatted
  • mathematica_variable - name of the variable to look for in Mathematica text (without subscript or identifying number)
  • python_variable - the variable to use instead
  • format - the form of the Mathematica text (optional, currently there is only support for raw input form)

Updated