Skip to main content

A fast python library for finding both min and max 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.

  • Written in C and takes advantage of AVX2 for speed
  • Roughly 2.3x faster than 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

$ 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

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.0-pp39-pypy39_pp73-win_amd64.whl (9.7 kB view hashes)

Uploaded PyPy Windows x86-64

numpy_minmax-0.1.0-pp39-pypy39_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.9 kB view hashes)

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

numpy_minmax-0.1.0-pp38-pypy38_pp73-win_amd64.whl (9.7 kB view hashes)

Uploaded PyPy Windows x86-64

numpy_minmax-0.1.0-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.9 kB view hashes)

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

numpy_minmax-0.1.0-cp311-cp311-win_amd64.whl (10.6 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

numpy_minmax-0.1.0-cp311-cp311-musllinux_1_1_x86_64.whl (20.2 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

numpy_minmax-0.1.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.9 kB view hashes)

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

numpy_minmax-0.1.0-cp310-cp310-win_amd64.whl (10.6 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

numpy_minmax-0.1.0-cp310-cp310-musllinux_1_1_x86_64.whl (20.1 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

numpy_minmax-0.1.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.9 kB view hashes)

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

numpy_minmax-0.1.0-cp39-cp39-win_amd64.whl (10.6 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

numpy_minmax-0.1.0-cp39-cp39-musllinux_1_1_x86_64.whl (20.1 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

numpy_minmax-0.1.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.9 kB view hashes)

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

numpy_minmax-0.1.0-cp38-cp38-win_amd64.whl (10.6 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

numpy_minmax-0.1.0-cp38-cp38-musllinux_1_1_x86_64.whl (20.6 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

numpy_minmax-0.1.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.1 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