Code Monkey home page Code Monkey logo

numpy-buffer's Introduction

Build Status

Numpy Buffer

A Python NumPy implementation of buffer.

Install

$ pip install git+https://github.com/scls19fr/numpy-buffer/

Ring Buffer

Description

See description of a ring buffer (or circular buffer).

Usage

In [1]: from numpy_buffer import RingBuffer

In [2]: N = 10

In [3]: ring = RingBuffer(size_max=10, default_value=0.0, dtype=float)

In [4]: ring
Out[4]:
<RingBuffer
    all:     array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.])
    partial: array([], dtype=float64)
    size/size_max: 0 / 10
>

In [5]: ring.append(1.2)

In [6]: ring
Out[6]:
<RingBuffer
    all:     array([ 1.2 ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0.])
    partial: array([ 1.2])
    size/size_max: 1 / 10
>

In [7]: ring.append(2.1)

In [8]: ring
Out[8]:
<RingBuffer
    all:     array([ 2.1 ,  1.2 ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0.,  0.])
    partial: array([ 2.1 ,  1.2])
    size/size_max: 2 / 10
>

In [9]: ring.all
Out[9]: array([ 2.1,  1.2,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ])

In [10]: ring.partial
Out[10]: array([ 2.1,  1.2])

In [11]: ring.partial[::-1]
Out[11]: array([ 1.2,  2.1])

Development

You can help to develop this library.

Issues

You can submit issues using https://github.com/scls19fr/numpy-buffer/issues

Clone

You can clone repository to try to fix issues yourself using:

$ git clone https://github.com/scls19fr/numpy-buffer

Run unit tests

Run all unit tests

$ nosetests -s -v

Run a given test

$ nosetests tests/test_ring.py:test_ring -s -v

Install development version

$ python setup.py install

or

$ sudo pip install git+https://github.com/scls19fr/numpy-buffer

Collaborating

  • Fork repository
  • Create a branch which fix a given issue
  • Submit pull requests

https://help.github.com/categories/collaborating/

Examples

see samples directory

image

numpy-buffer's People

Contributors

lwalter86 avatar scls19fr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

numpy-buffer's Issues

ring.all or ring.all[::-1] ?

I wonder if array shouldn't be reversed

In matplotlib example it will be possible to do

line.set_ydata(data_y.all)

instead of

line.set_ydata(data_y.all[::-1])

zeros after

We have

In [9]: ring.all
Out[9]: array([ 2.1,  1.2,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ])

which is displayed as

array([ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. , 1.2,  2.1 ])

we might also have a method to display data as

array([ 1.2,  2.1, 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ])

which should be

In [10]: ring.????
Out[9]: array([ 0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. ,  0. , 2.1,  1.2 ])

Pandas Buffer

A Pandas implementation of ring buffer could be a interesting idea.

That's probably out of the scope of this project but that's definitely something to consider for heterogeneous data.

Publish on PyPi

 $ pip install numpy-buffer

raises an error because

Package should be pusblished on PyPi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.