本文整理匯總了Python中MA.arrayrange方法的典型用法代碼示例。如果您正苦於以下問題:Python MA.arrayrange方法的具體用法?Python MA.arrayrange怎麽用?Python MA.arrayrange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MA
的用法示例。
在下文中一共展示了MA.arrayrange方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_arraydict
# 需要導入模塊: import MA [as 別名]
# 或者: from MA import arrayrange [as 別名]
def test_arraydict(self):
def _check(a):
self.assertEqual(a['na'], na)
self.assertEqual(a['maa'], maa)
self.assertEqual(a['na'][500:-500], na[500:-500])
self.assertEqual(a['maa'][500:-500], maa[500:-500])
scatter = Numeric.array(xrange(0, len(na), 3))
self.assertEqual(a['na'].take(scatter), Numeric.take(na, scatter))
self.assertEqual(Numeric.take(a['na'],scatter),
Numeric.take(na, scatter))
self.assertEqual(MA.take(a['maa'], scatter), MA.take(maa, scatter))
tmpfile = TempFile('soomtestarray_tmpfile')
try:
a = soomarray.ArrayDict(tmpfile.fn(), 'w')
self.assertEqual(len(a), 0)
self.assertRaises(KeyError, a.__getitem__, 'not_found')
na = Numeric.arrayrange(10000)
a['na'] = na
na[1000] = -2222
# MmapArray __setitem__
a['na'][1000] = -2222
maa = MA.arrayrange(10000)
for i in xrange(0, len(maa), 5):
maa[i] = MA.masked
a['maa'] = maa
maa[1000] = -2222
a['maa'][1000] = -2222
_check(a)
del a
a = soomarray.ArrayDict(tmpfile.fn(), 'r')
_check(a)
finally:
try: del a
except UnboundLocalError: pass
tmpfile.done()
示例2: list
# 需要導入模塊: import MA [as 別名]
# 或者: from MA import arrayrange [as 別名]
# Tutorial for xmgrace module, using Numeric only
# 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()