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