Skip to main content

A fast python library for finding both min and max value in a NumPy array

Project description

numpy-minmax: a fast function for finding the minimum and maximum value in a NumPy array

NumPy lacked an optimized minmax function, so we wrote our own. At Nomono, we use it for audio processing, but it can be applied any kind of float32 ndarray.

  • Written in C and takes advantage of AVX/AVX512 for speed
  • Roughly 2.3x speedup compared to the numpy amin+amax equivalent (tested on Intel CPU with numpy 1.24-1.26)
  • The fast implementation is tailored for float32 arrays that are C-contiguous, F-contiguous or 1D strided. Strided arrays with ndim >= 2 get processed with numpy.amin and numpy.amax, so no perf gain there.

Installation

PyPI version python 3.8, 3.9, 3.10, 3.11, 3.12 os: Linux, macOS, Windows

$ pip install numpy-minmax

Usage

import numpy_minmax
import numpy as np

arr = np.arange(1337, dtype=np.float32)
min_val, max_val = numpy_minmax.minmax(arr)  # 0.0, 1336.0

Changelog

[0.3.1] - 2024-08-15

Changes

  • Optimize (with AVX) the processing of contiguous int16 arrays. ~2.3x speedup compared to 0.3.0

For the complete changelog, go to CHANGELOG.md

Development

  • Install dev/build/test dependencies as denoted in pyproject.toml
  • CC=clang pip install -e .
  • pytest

Running benchmarks

  • Install diplib pip install diplib
  • python scripts/perf_benchmark.py

Acknowledgements

This library is maintained/backed by Nomono, a Norwegian audio AI startup.

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

numpy_minmax-0.3.1.tar.gz (13.0 kB view hashes)

Uploaded Source

Built Distributions

numpy_minmax-0.3.1-pp39-pypy39_pp73-win_amd64.whl (13.4 kB view hashes)

Uploaded PyPy Windows x86-64

numpy_minmax-0.3.1-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (12.1 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

numpy_minmax-0.3.1-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_minmax-0.3.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl (10.4 kB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

numpy_minmax-0.3.1-pp38-pypy38_pp73-win_amd64.whl (13.4 kB view hashes)

Uploaded PyPy Windows x86-64

numpy_minmax-0.3.1-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (12.1 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

numpy_minmax-0.3.1-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_minmax-0.3.1-pp38-pypy38_pp73-macosx_11_0_arm64.whl (10.4 kB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

numpy_minmax-0.3.1-cp312-cp312-win_amd64.whl (14.5 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

numpy_minmax-0.3.1-cp312-cp312-musllinux_1_2_x86_64.whl (28.6 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.2+ x86-64

numpy_minmax-0.3.1-cp312-cp312-musllinux_1_2_aarch64.whl (21.4 kB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.2+ ARM64

numpy_minmax-0.3.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (22.0 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

numpy_minmax-0.3.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (30.3 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_minmax-0.3.1-cp312-cp312-macosx_11_0_arm64.whl (12.3 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

numpy_minmax-0.3.1-cp311-cp311-win_amd64.whl (14.5 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

numpy_minmax-0.3.1-cp311-cp311-musllinux_1_2_x86_64.whl (28.4 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ x86-64

numpy_minmax-0.3.1-cp311-cp311-musllinux_1_2_aarch64.whl (21.3 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ ARM64

numpy_minmax-0.3.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (21.8 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

numpy_minmax-0.3.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (30.0 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_minmax-0.3.1-cp311-cp311-macosx_11_0_arm64.whl (12.3 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

numpy_minmax-0.3.1-cp310-cp310-win_amd64.whl (14.5 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

numpy_minmax-0.3.1-cp310-cp310-musllinux_1_2_x86_64.whl (28.4 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ x86-64

numpy_minmax-0.3.1-cp310-cp310-musllinux_1_2_aarch64.whl (21.3 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ ARM64

numpy_minmax-0.3.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (21.8 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

numpy_minmax-0.3.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (30.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_minmax-0.3.1-cp310-cp310-macosx_11_0_arm64.whl (12.3 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

numpy_minmax-0.3.1-cp39-cp39-win_amd64.whl (14.5 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

numpy_minmax-0.3.1-cp39-cp39-musllinux_1_2_x86_64.whl (28.4 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ x86-64

numpy_minmax-0.3.1-cp39-cp39-musllinux_1_2_aarch64.whl (21.3 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ ARM64

numpy_minmax-0.3.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (21.8 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

numpy_minmax-0.3.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (30.0 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_minmax-0.3.1-cp39-cp39-macosx_11_0_arm64.whl (12.3 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

numpy_minmax-0.3.1-cp38-cp38-win_amd64.whl (14.5 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

numpy_minmax-0.3.1-cp38-cp38-musllinux_1_2_x86_64.whl (28.6 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ x86-64

numpy_minmax-0.3.1-cp38-cp38-musllinux_1_2_aarch64.whl (21.4 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ ARM64

numpy_minmax-0.3.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (21.9 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

numpy_minmax-0.3.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (30.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

numpy_minmax-0.3.1-cp38-cp38-macosx_11_0_arm64.whl (12.3 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

Supported by

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