本文整理匯總了Python中numpy.matlib方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.matlib方法的具體用法?Python numpy.matlib怎麽用?Python numpy.matlib使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy
的用法示例。
在下文中一共展示了numpy.matlib方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: writer
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import matlib [as 別名]
def writer(ring):
for i in range(10000):
m = numpy.matlib.randn(25, 100)
x = numpy.ctypeslib.as_ctypes(m)
try:
ring.try_write(x)
except ringbuffer.WaitingForReaderError:
print('Reader is too slow, dropping %r' % x)
continue
if i and i % 100 == 0:
print('Wrote %d so far' % i)
ring.writer_done()
print('Writer is done')
示例2: reader
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import matlib [as 別名]
def reader(ring, pointer):
while True:
try:
data = ring.blocking_read(pointer)
except ringbuffer.WriterFinishedError:
return
x = numpy.frombuffer(data)
x.shape = (25, 100)
x[1, 1] = 1.1 # Verify it's mutable
m = numpy.matlib.asmatrix(x)
norm = numpy.linalg.norm(m)
print('Reader %r is done' % pointer)