import scipy as sp import numpy as np import mango.mpi as mpi import math logger, rootLogger = mpi.getLoggers(__name__) def rotation_matrix(angle, axis, dim=3, dtype="float64"): """ Returns rotation matrix for specified degree angle and coordinate axis of rotation. :type angle: :obj:`float` :param angle: Angle of rotation in degrees. :type axis: :obj:`int` :param axis: Index of the axis of rotation (for :samp:`{dim}=3`, :samp:`{axis}=0` is the z-axis, :samp:`{axis}=1` is the y-axis and:samp:`{axis}=2` is the x-axis. :type dim: :obj:`int` :param dim: Rotation spatial dimension. :rtype: :obj:`numpy.array` :return: A :samp:`(dim, dim)` shaped rotation matrix. """ I = sp.eye(dim, dim, dtype=dtype) u = sp.zeros((dim, 1), dtype=dtype) v = sp.zeros((dim, 1), dtype=dtype) u[(axis + dim - 2) % dim] = 1 v[(axis + dim - 1) % dim] = 1
try: # Import the set class, python2 only, python3 has set as a built-in. import sets.Set as set except: pass import inspect import mango import mango.mpi as mpi from mango.application.main_driver import MainDriverFilter from mango.application.main_driver import getAllRegisteredMainDriverFilterClasses # Import XML element-tree parser, use this to validate XML. import xml.etree.ElementTree as ET logger, rootLogger = mpi.getLoggers(__name__) _xmlDocRe = re.compile("\\s*\\<\\?\\s*xml\\s*version\\s*=.*\\?\\>\\s+(.*)") def makeXmlDoc(xmlStr): """ Turns XML tag string into XML document which can be validated by :obj:`xml.etree.ElementTree` parser. Simply adds the :samp:`'<? xml version=\"1.0\"?>'` header string and global enclosing tags of :samp:`<mango>...</mango>`. :type xmlStr: :obj:`str` :param xmlStr: String of XML. :rtype: :obj:`str` :return: XML document string. """ xmlDocStr = xmlStr if (re.match(_xmlDocRe, xmlDocStr) == None): xmlDocStr = ("<?xml version=\"1.0\"?>\n<mango>\n%s\n</mango>" % xmlStr)