本文整理汇总了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()