Python numpy.matlib() Examples
The following are 2 code examples for showing how to use numpy.matlib(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
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')
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)