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 also be applied to other kinds of data of similar shape.

  • Written in C and takes advantage of AVX2 for speed
  • Roughly 2.3x speedup compared to the numpy amin+amax equivalent (tested with numpy 1.24-1.26)
  • The fast implementation is tailored for C-contiguous 1-dimensional and 2-dimensional float32 arrays. Other types of arrays 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 os: Linux, 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

Development

  • Install dev/build/test dependencies as denoted in setup.py
  • 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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

numpy_minmax-0.1.1-pp39-pypy39_pp73-win_amd64.whl (11.6 kB view hashes)

Uploaded PyPy Windows x86-64

numpy_minmax-0.1.1-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.4 kB view hashes)

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

numpy_minmax-0.1.1-pp38-pypy38_pp73-win_amd64.whl (11.6 kB view hashes)

Uploaded PyPy Windows x86-64

numpy_minmax-0.1.1-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.4 kB view hashes)

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

numpy_minmax-0.1.1-cp311-cp311-win_amd64.whl (12.3 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

numpy_minmax-0.1.1-cp311-cp311-musllinux_1_1_x86_64.whl (18.7 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

numpy_minmax-0.1.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.4 kB view hashes)

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

numpy_minmax-0.1.1-cp310-cp310-win_amd64.whl (12.3 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

numpy_minmax-0.1.1-cp310-cp310-musllinux_1_1_x86_64.whl (18.7 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

numpy_minmax-0.1.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.4 kB view hashes)

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

numpy_minmax-0.1.1-cp39-cp39-win_amd64.whl (12.3 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

numpy_minmax-0.1.1-cp39-cp39-musllinux_1_1_x86_64.whl (18.8 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

numpy_minmax-0.1.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.4 kB view hashes)

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

numpy_minmax-0.1.1-cp38-cp38-win_amd64.whl (12.3 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

numpy_minmax-0.1.1-cp38-cp38-musllinux_1_1_x86_64.whl (19.2 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

numpy_minmax-0.1.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.5 kB view hashes)

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

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