array-api-signal
Signal processing primitives (windows, filters, integration) for the Python Array API Standard.
array-api-signal is a lightweight extension library that brings scientific computing capabilities—similar to
scipy.signal and scipy.integrate—to the Python Array API ecosystem.
It allows you to write signal processing code that runs unmodified on NumPy, PyTorch, CuPy, JAX, and * Dask*.
Why?
The Python Array API Standard unifies basic array operations (sin, matmul, reshape), and array-api-extra
provides common utilities (pad, kron).
However, scientific domains often need higher-level primitives like Simpson's rule integration, **window generation
**, or smoothing filters. array-api-signal fills this gap, providing a single namespace that:
- Implements missing primitives (like
xp.simpson) using backend-agnostic operations. - Re-exports
array-api-extrafunctions (likexp.pad). - Dispatches standard API calls (like
xp.sin) to the underlying backend.
This library is designed to be the "SciPy" companion to array-api-compat's "NumPy".
Installation
pip install array-api-signal
Quick Start: The Unified Namespace
The core philosophy is the Unified Namespace. You rarely need to import numpy or torch directly for your processing logic.
import array_api_signal as aps
import numpy as np
import torch
# 1. Start with any array (NumPy or Torch)
x_np = np.linspace(0, 10, 100)
x_torch = torch.linspace(0, 10, 100, device='cuda')
# 2. Get the unified 'xp' namespace
# This object has EVERYTHING: standard API + signal extensions + extra utils
xp = aps.array_namespace(x_torch)
# 3. Write backend-agnostic code
y = xp.sin(x_torch) # Calls torch.sin (Standard API)
y = xp.pad(y, (2, 2)) # Calls array_api_extra.pad (Extra API)
area = xp.simpson(y, dx=0.1) # Calls array_api_signal.simpson (Signal API)
print(f"Area on GPU: {area}") # Returns a Torch tensor
API Reference
1. Integration (xp.integrate)
Robust numerical integration with support for native backend optimizations (e.g., torch.trapezoid).
xp.trapezoid(y, x=None, dx=1.0, axis=-1): Composite trapezoidal rule.xp.simpson(y, x=None, dx=1.0, axis=-1): Composite Simpson's rule. Matchesscipy.integrate.simpsonbehavior (using the trapezoidal rule for the last interval if samples are even).
2. Signal Processing (xp.signal)
Filtering and convolution tools. Dispatches to scipy.ndimage (NumPy) or torch.nn.functional (Torch) for maximum performance.
xp.gaussian_filter1d(input, sigma, ...): 1D Gaussian smoothing.xp.convolve(in1, in2, mode='full'): General 1D convolution (via FFT).
3. Window Functions (xp.windows)
Backend-agnostic window generation. If you use the unified xp object, these functions automatically return arrays on the correct backend.
xp.hann(M, sym=True): Hann window.xp.hamming(M, sym=True): Hamming window.xp.tukey(M, alpha=0.5, sym=True): Tukey (tapered cosine) window.
4. Special Functions (xp.special)
Backend-native special functions the Array API standard omits.
xp.i0e(x): Exponentially scaled modified Bessel functionI_0(x) * exp(-|x|).xp.ndtr(x): Standard normal CDFPhi(x).xp.logsumexp(x, axis=None, keepdims=False): Overflow-safelog(sum(exp(x))).xp.interp(x, x_ref, f_ref): Edge-clamped 1-D linear interpolation (matchesnumpy.interp, including infinitef_refvalues).
Backend support: logsumexp and interp have portable fallbacks and work on
every backend. i0e and ndtr dispatch to scipy.special (NumPy) or torch
(PyTorch); they have no portable Array API formulation, so on other backends
(JAX, CuPy, Dask) they raise NotImplementedError.
5. Extensions from array-api-extra
We re-export widely used extensions so you only need one import.
xp.padxp.sincxp.covxp.kron
Contributing
We welcome contributions! If you have implemented a scipy function (like a specific filter, window, or transform) using only standard Array API primitives, please submit a PR.
Running Tests
We use pytest to verify correctness against scipy (Gold Standard) across all installed backends.
# Run tests
pytest tests/
# Test specific backend
pytest tests/ --backend=torch
Metadata
Release files for array-api-signal 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| array_api_signal-0.2.0.tar.gz | 32.5 kB | Without provenance | Details for array_api_signal-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| array_api_signal-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for array_api_signal-0.2.0-py3-none-any.whl |
Total release size: 55.0 kB
Release files / array_api_signal-0.2.0.tar.gz
| Download URL | array_api_signal-0.2.0.tar.gz |
|---|---|
| Size | 32.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5e728f5487749f2f13e91fc650fc20a12461900055b349366ba4ccf9927c6c3
|
|
BLAKE2b-256 checksum How to use checksums |
037315c23c59fd478fa123901134e7ba476782e00ed44afc0c4a3dae43b9a0be
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Release files / array_api_signal-0.2.0-py3-none-any.whl
| Download URL | array_api_signal-0.2.0-py3-none-any.whl |
|---|---|
| Size | 22.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bbadd5126d5951a859ffd44ef58d65330f96f9b1999986d464f4031250a80e5f
|
|
BLAKE2b-256 checksum How to use checksums |
26f21a9164b11b35e28f4f3971b48891a8f446b78a8fe7bd94983aacb698ce07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.3
|
Security for array-api-signal 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.