Skip to content

Instantly share code, notes, and snippets.

@keunwoochoi
Forked from bmcfee/pescador_example.py
Created August 4, 2016 05:06
Show Gist options
  • Save keunwoochoi/0184744dd72782d4f94db73c6a9b4c94 to your computer and use it in GitHub Desktop.
Save keunwoochoi/0184744dd72782d4f94db73c6a9b4c94 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import numpy as np
import pescador
def data_sampler(filename, n_samples):
# Load all the data from the file, somehow
data = load_data(filename)
for n in range(n_samples):
x, y = sample(data)
yield dict(x=x, y=y)
stream = pescador.Streamer(data_sampler, n_samples=128)
streamer = pescador.zmq_stream(stream)
for sample in steamer:
process(sample)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment