Example #1
0
 def testTrig (self):
     "Test sin, cos, tan, and their inverses"
     assert eq (MA.arccos(-1.0), MA.pi)
     assert eq (MA.sin(self.a), map(math.sin, self.a))
     assert eq (MA.cos(self.a), map(math.cos, self.a))
     assert eq (MA.tan(self.a), map(math.tan, self.a))
     assert eq (MA.arccos(self.a), map(math.acos, self.a))
     assert eq (MA.arcsin(self.a), map(math.asin, self.a))
     assert eq (MA.arctan(self.a), map(math.atan, self.a))
     assert MA.sin(self.m).shape == self.m.shape
     assert MA.cos(self.m).shape == self.m.shape
     assert MA.tan(self.m).shape == self.m.shape
     assert MA.arcsin(self.m).shape == self.m.shape
     assert MA.arccos(self.m).shape == self.m.shape
     assert MA.arctan(self.m).shape == self.m.shape
     assert eq (MA.sin(self.m).flat, map(math.sin, self.m.flat))
     assert eq (MA.cos(self.m).flat, map(math.cos, self.m.flat))
     assert eq (MA.tan(self.m).flat, map(math.tan, self.m.flat))
     assert eq (MA.arcsin(self.m).flat, map(math.asin, self.m.flat))
     assert eq (MA.arccos(self.m).flat, map(math.acos, self.m.flat))
     assert eq (MA.arctan(self.m).flat, map(math.atan, self.m.flat))
# it is recomended to run it usibng parser.py or just read it

print 'it is recomended to run this file using parser.py or just read it'

import MA

TEMPDIR = './'

# First let's create some data
npoints=50
X=MA.arrayrange(npoints,typecode=MA.Float)
X=X/float(npoints)*2.*MA.pi

Y1=MA.sin(X)
Y2=MA.cos(X)
Y3=MA.tan(X)

# Now the real grace thing, plot the 2 on one graph and the diff on another graph

from genutil import xmgrace # first we need to import xmgrace module

x=xmgrace.init() # create our xmgrace object

# First let's set our graphs area
# graph 0, exist by default, but we need to add 1 graph, therefore:
x.add_graph() # adds one graph to our graph list (x.Graph)

# Let's change the orientation of the page to portrait
x.portrait()