Skip to main content

NumPy ndarray subclass with rolling-window operations.

Project description

arrayflux

CI/CD Pipeline Code Coverage Latest Release License Platform

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.0.tar.gz (5.4 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.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file arrayflux-0.1.0.tar.gz.

File metadata

  • Download URL: arrayflux-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 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.0.tar.gz
Algorithm Hash digest
SHA256 f774a9b2b9f790e6a5a4950d5085734d76b9b0ed1e584b307b67ad104a396b87
MD5 077f10300b39785bfc094dc95efc7224
BLAKE2b-256 5af392dcf9fcde6133ebd4a78ee9051226d680351d578ce5caa30d031bb4f00a

See more details on using hashes here.

File details

Details for the file arrayflux-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: arrayflux-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc6ba4c9b32a25976d643327faa43c45376a4a0b5ba000ce2839a96b4e035ba0
MD5 d535ab60b5924e28fdab8ffd63b7e233
BLAKE2b-256 29edc19a0e7e71e6cfe376a7b6101810cd1436b08aa6d07325cfdfd2a31d3c7a

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