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
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
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 details)
File details
Details for the file window_slider-0.8.zip
.
File metadata
- Download URL: window_slider-0.8.zip
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65b24b4ad5a020222e68b005fbbf154193498b7071a1ff14050b8336fe5f8e45 |
|
MD5 | 701342fa0df2be8c4e04e1b01f52999f |
|
BLAKE2b-256 | 5f440a2bce60022902238aac90bd933de9b9ac2215811115afc03ed39db2b9c5 |