Skip to main content

A lib to implement sliding window with overlapping on numpy array

Project description

A python package to run sliding window with overlapping on numpy array

Status

Build Status PyPI last commit License FOSSA Status PyPI Package monthly downloads PyPI download week

Usage

$ pip install window-slider

$ python

from window_slider import Slider
import numpy
list = numpy.array([0, 1, 2, 3, 4, 5, 6, 7])
bucket_size = 3
overlap_count = 1
slider = Slider(bucket_size,overlap_count)
slider.fit(list)       
while True:
    window_data = slider.slide()
    # do your stuff
    print(window_data)
    if slider.reached_end_of_list(): break

numpy 2D array

from window_slider import Slider
import numpy
list = numpy.array([[0, 1, 2, 3],[0, 1, 2, 3]])
bucket_size = 3
overlap_count = 1
slider = Slider(bucket_size,overlap_count)
slider.fit(list)       
while True:
    window_data = slider.slide()
    # do your stuff
    print(window_data)
    if slider.reached_end_of_list(): break

wrap window data to custom class

class WindowData(object):
    def __init__(self, data):
        self._data = data
    
    def sum(self):
        return sum(self._data)
        

from window_slider import Slider
import numpy
list = numpy.array([0, 1, 2, 3, 4, 5, 6, 7])
bucket_size = 3
overlap_count = 1
slider = Slider(bucket_size,overlap_count,WindowData)
slider.fit(list)       
while True:
    window_data = slider.slide()
    # do your stuff
    print(window_data.sum())
    if slider.reached_end_of_list(): break

License

FOSSA Status

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

window_slider-0.8.zip (6.0 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page