NumPy ndarray subclass with rolling-window operations.
Project description
arrayflux
Tired of not having rolling method on NumPy arrays I created arrayflux!
arrayflux is a lightweight, production-ready Python library that extends
numpy.ndarray with efficient rolling-window operations, fully compatible with
NumPy semantics, slicing, memory model, and ufunc system.
📦 Installation (PyPI Package)
pip install arrayflux
⚙️ Usage Example
from arrayflux import arrayflux
x = arrayflux([1, 2, 3, 4, 5, 6])
r = x.rolling(3)
print(r.mean()) # [nan nan 2. 3. 4. 5.]
💡 How it works
I was tired of not having a native rolling method on NumPy arrays, and since I didn’t want to use pandas for this specific need, I created arrayflux. The idea is simple: extend NumPy’s ndarray with a clean and intuitive .rolling() API while keeping full NumPy compatibility and behavior.
Under the hood, the user interacts only with a small public API exposed in api.py, which provides a function that accepts any iterable and returns an ArrayFlux object. The ArrayFlux class itself lives in core.py, where the new method converts the input iterable into a NumPy array and applies .view(ArrayFlux) so that the object keeps all ndarray properties. The same class implements the .rolling(window) method, which performs a lazy import of the Rolling class and instantiates it using the desired window size. The Rolling class, defined in rolling.py, builds the actual rolling-window representation using numpy.lib.stride_tricks.sliding_window_view. All rolling operations (mean, std, var, skew, kurtosis, covariance, correlation, etc.) operate directly on this windowed view, and results are padded with leading NaN values to preserve the original array length.
The goal of arrayflux is to provide a lightweight, NumPy-native rolling system that is easy to use, easy to integrate, and fast to compute, without relying on heavier dependencies or abandoning the ndarray model.
🪪 License
MIT © 2025 — Developed with ❤️ by Lorenzo Santarsieri
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file arrayflux-0.1.1.tar.gz.
File metadata
- Download URL: arrayflux-0.1.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7261af5f042fb1568022b6c9f9dad2132b3397a5ebf3cf3bf0d4db81d771f2a
|
|
| MD5 |
ff6ca4bce4d460dac6b5c7c5f1607c2e
|
|
| BLAKE2b-256 |
e1f383a293e8ba8754d4061a6bf705efa1b0753b1709ca956ad2977b306bdd5f
|
File details
Details for the file arrayflux-0.1.1-py3-none-any.whl.
File metadata
- Download URL: arrayflux-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1acae54eea89b0bfa4848afc693413e7cc272945205d4b31f25ea972defcde65
|
|
| MD5 |
4f32b59064bdc887980ca938cf4df094
|
|
| BLAKE2b-256 |
8434195dc58a705d251c7d3b6edea56d10f298da3c619c1d08bb3ff064dd8f8e
|