本文整理汇总了Python中RandomArray.randint方法的典型用法代码示例。如果您正苦于以下问题:Python RandomArray.randint方法的具体用法?Python RandomArray.randint怎么用?Python RandomArray.randint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RandomArray
的用法示例。
在下文中一共展示了RandomArray.randint方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RunMovie
# 需要导入模块: import RandomArray [as 别名]
# 或者: from RandomArray import randint [as 别名]
def RunMovie(self,event = None):
import RandomArray
start = clock()
shift = RandomArray.randint(0,0,(2,))
NumFrames = 50
for i in range(NumFrames):
points = self.LEs.Points
shift = RandomArray.randint(-5,5,(2,))
points += shift
self.LEs.SetPoints(points)
self.Canvas.Draw()
print "running the movie took %f seconds to disply %i frames"%((clock() - start),NumFrames)
示例2: test_sparse_vs_dense
# 需要导入模块: import RandomArray [as 别名]
# 或者: from RandomArray import randint [as 别名]
def test_sparse_vs_dense(self):
RandomArray.seed(0) # For reproducability
for s, l in (100, 100000), (10000, 100000), (100000, 100000):
small = Numeric.sort(RandomArray.randint(0, 100000, (s,)))
large = Numeric.sort(RandomArray.randint(0, 100000, (l,)))
sparse1 = soomfunc.sparse_intersect(small, large)
sparse2 = soomfunc.sparse_intersect(large, small)
dense1 = soomfunc.dense_intersect(small, large)
dense2 = soomfunc.dense_intersect(large, small)
self.assertEqual(sparse1, sparse2)
self.assertEqual(dense1, dense2)
self.assertEqual(sparse1, dense1)
示例3: random_tree
# 需要导入模块: import RandomArray [as 别名]
# 或者: from RandomArray import randint [as 别名]
def random_tree(labels):
"""
Given a list of labels, create a list of leaf nodes, and then one
by one pop them off, randomly grafting them on to the growing tree.
Return the root node.
"""
assert len(labels) > 2
import RandomArray; RandomArray.seed()
leaves = []
for label in labels:
leaves.append(Fnode(istip=1, label=label))
leaf_indices = list(RandomArray.permutation(len(leaves)))
joined = [leaves[leaf_indices.pop()]]
remaining = leaf_indices
while remaining:
i = RandomArray.randint(0, len(joined)-1)
c1 = joined[i]
if c1.back:
n = c1.bisect()
else:
n = InternalNode()
n.add_child(c1)
c = leaves[remaining.pop()]
n.add_child(c)
joined.append(c)
joined.append(n)
for node in joined:
if not node.back:
node.isroot = 1
return node
示例4: sampled_ds
# 需要导入模块: import RandomArray [as 别名]
# 或者: from RandomArray import randint [as 别名]
def sampled_ds(parent_dataset, sample, name=None, filter_label=None, **kwargs):
parent_len = len(parent_dataset)
samp_len = int(parent_len * sample)
record_ids = Numeric.sort(RandomArray.randint(0, parent_len, samp_len))
if name is None:
name = 'samp%02d_%s' % (sample * 100, parent_dataset.name)
if filter_label is None:
filter_label = '%.3g%% sample' % (sample * 100)
return FilteredDataset(parent_dataset, record_ids, name=name,
filter_label=filter_label, **kwargs)
示例5: ll_mat
# 需要导入模块: import RandomArray [as 别名]
# 或者: from RandomArray import randint [as 别名]
from pysparse.spmatrix import *
import RandomArray
import time
n = 1000
nnz = 50000
A = ll_mat(n, n, nnz)
R = RandomArray.randint(0, n, (nnz,2))
t1 = time.clock()
for k in xrange(nnz):
A[R[k,0],R[k,1]] = k
print 'Time for populating matrix: %8.2f sec' % (time.clock() - t1, )
print A.nnz
B = A[:,:]
A.shift(-1.0, B)
print A
示例6: randomBits
# 需要导入模块: import RandomArray [as 别名]
# 或者: from RandomArray import randint [as 别名]
def randomBits(length):
address = RandomArray.randint(0, 2, length)
return address
示例7: TestFrame
# 需要导入模块: import RandomArray [as 别名]
# 或者: from RandomArray import randint [as 别名]
import wx
import numarray
from numarray import random_array
import RandomArray # the Numeric version
import time
NumLinePoints = 5000
NumPointPoints = 5000
## Make some random data to draw things with.
MaxX = 500
LinesPoints = random_array.randint(1, MaxX, (NumLinePoints,2) )
#PointsPoints = random_array.randint(1, MaxX, (NumPointPoints,2) )
PointsPoints = RandomArray.randint(1, MaxX, (NumPointPoints,2) ) # Numeric
class TestFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "DrawLines Test",
wx.DefaultPosition,
size=(500,500),
style=wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE)
## Set up the MenuBar
MenuBar = wx.MenuBar()
file_menu = wx.Menu()
ID_EXIT_MENU = wx.NewId()