NumPy RMS
numpy-rms is a fast Python library designed for calculating the Root Mean Square (RMS) of NumPy arrays. It leverages C implementations with SIMD acceleration (AVX on x86-64, NEON on ARM) to provide significant performance benefits, especially for 1-dimensional and 2-dimensional C-contiguous float32 arrays. The current version is 0.6.0, with a fairly active release cadence.
Warnings
- gotcha The library is specifically optimized for C-contiguous 1-dimensional and 2-dimensional NumPy arrays of `float32` dtype. Using other data types (e.g., `float64`) or non-contiguous array layouts might lead to reduced performance or unexpected behavior compared to its advertised speed.
- gotcha As `numpy-rms` is implemented in C and interacts with NumPy's C API, major NumPy version updates (e.g., NumPy 2.0 and above) can introduce Application Binary Interface (ABI) incompatibilities. This may require `numpy-rms` to be rebuilt or updated by its maintainers to ensure compatibility, potentially causing `ImportError` or runtime issues if using an older `numpy-rms` binary with a new NumPy version.
- gotcha The project is currently classified with a 'Development Status :: 3 - Alpha' on PyPI. This indicates that while functional, the API may not be entirely stable and could undergo breaking changes in future minor releases, even if semver is generally followed.
Install
-
pip install numpy-rms
Imports
- rms
import numpy_rms rms_value = numpy_rms.rms(arr, window_size=10)
Quickstart
import numpy_rms
import numpy as np
arr = np.arange(40, dtype=np.float32)
rms_series = numpy_rms.rms(arr, window_size=10)
print(f"Original array shape: {arr.shape}")
print(f"RMS series shape: {rms_series.shape}")
print(f"First few RMS values: {rms_series[:5]}")