Skip to main content

NumPy ndarray subclass with rolling-window operations.

Project description

arrayflux

Python NumPy SciPy PyTest Rolling Subclass

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


Download files

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

Source Distribution

arrayflux-0.1.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

arrayflux-0.1.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

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

Hashes for arrayflux-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a7261af5f042fb1568022b6c9f9dad2132b3397a5ebf3cf3bf0d4db81d771f2a
MD5 ff6ca4bce4d460dac6b5c7c5f1607c2e
BLAKE2b-256 e1f383a293e8ba8754d4061a6bf705efa1b0753b1709ca956ad2977b306bdd5f

See more details on using hashes here.

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

Hashes for arrayflux-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1acae54eea89b0bfa4848afc693413e7cc272945205d4b31f25ea972defcde65
MD5 4f32b59064bdc887980ca938cf4df094
BLAKE2b-256 8434195dc58a705d251c7d3b6edea56d10f298da3c619c1d08bb3ff064dd8f8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page