Numpy Bool Argmax Ext

Additional helper methods to improve numpy.argmax performance for 1D boolean arrays with strides
Alternatives To Numpy Bool Argmax Ext
Project NameStarsDownloadsRepos Using ThisPackages Using ThisMost Recent CommitTotal ReleasesLatest ReleaseOpen IssuesLicenseLanguage
Alphalens2,110143a year ago9April 27, 202042apache-2.0Jupyter Notebook
Performance analysis of predictive (alpha) stock factors
Fast Pandas928
5 years ago2Python
Benchmark for different operations in pandas against various dataframe sizes.
Pyhpc Benchmarks258
2 months ago6unlicensePython
A suite of benchmarks for CPU and GPU performance of the most popular high-performance libraries for Python :rocket:
Matft89
a month ago13December 18, 20206bsd-3-clauseSwift
Numpy-like library in swift. (Multi-dimensional Array, ndarray, matrix and vector library)
Python Numpy C Extension Examples54
8 years agomitC
Example code for blog post.
Python Performance Minicourse53
a month agoJupyter Notebook
Mini-course at Princeton on High Performance Python
Pnumpy33
22 years ago25February 04, 202118mitC++
Parallel NumPy seamlessly speeds up NumPy for large arrays (64K+ elements) with no change required to existing code.
Pythoncextensions30
4 years ago1Python
Comparing the performance of Python, NumPy and C extensions
Masteringpython21
2 months agomitJupyter Notebook
Build high performance, concurrent, and multi-threaded apps with Python using proven design patterns
Benchmark Sharedmem14
7 years agomitPython
Performance test of NumPy shared memory module
Alternatives To Numpy Bool Argmax Ext
Select To Compare


Alternative Project Comparisons
Readme

Introduction

This library provides an alternative to numpy.argmax to get the maximum value in a 1D boolean array with strides, without performing a copy of the input array, and thus increasing the performance.

The rationale is explained in this stackoverflow question

Requirements

The only dependency is numpy.

For now, only tested with Python>=3.7 and numpy==1.16.4

Installation

Via setup.py script:

git clone https://github.com/Vykstorm/numpy-bool-argmax-ext.git
cd numpy-bool-argmax-ext
python setup.py install

Usage

Now you only need to use the function argmax defined in this library instead of np.argmax

e.g:

import numpy as np
from argmaxext import argmax

a = np.random.randint(0, 2, 10000, np.bool)
print(argmax(a))

Execute the next benchmark to compare both functions when dealing with boolean 1D arrays and -1 as stride value for example:

from timeit import timeit

a = np.zeros([2 ** 18], np.bool)
# Worst case scenario (only the first item is True)
a[0] = True

k = 10000
print("np.argmax(a[::-1]) average time: {:6f} msecs".format(
    1000*timeit(lambda: np.argmax(a[::-1]), number=k) / k
))

print("argmax(a[::-1]) average time: {:6f} msecs".format(
    1000*timeit(lambda: argmax(a[::-1]), number=k) / k
))
Popular Performance Projects
Popular Numpy Projects
Popular Software Performance Categories
Related Searches

Get A Weekly Email With Trending Projects For These Categories
No Spam. Unsubscribe easily at any time.
Python
C
Performance
Numpy