cfhamlet / os-fast-reservoir

Python implementation of fast approximation reservioir sampling.

Repository from Github https://github.comcfhamlet/os-fast-reservoirRepository from Github https://github.comcfhamlet/os-fast-reservoir

os-fast-reservoir

Build Status codecov PyPI - Python Version PyPI

Python implementation of fast approximation reservioir sampling.

Install

$ pip install os-fast-reservoir

Usage

  • API
  from os_fast_reservoir import ReservoirSampling

  rs = ReservoirSampling(100)

  for i in range(1000):
      rs.sample(i)

  for i in rs:
      print i
  • Command line
  $ os-fast-reservoir -h
  usage: os-fast-reservoir [-h] [-v] [-f FILES [FILES ...]] -n NUM

  Reservoir sample tool.

  optional arguments:
    -h, --help            show this help message and exit
    -v, --version         show program's version number and exit
    -f FILES [FILES ...], --files FILES [FILES ...]
                          files to be sampled (default: stdin)
    -n NUM, --num NUM     sample number

Algorithm

Unit Tests

$ tox

License

MIT licensed.

About

Python implementation of fast approximation reservioir sampling.

License:MIT License


Languages

Language:Python 100.0%