bottleneck

Fast NumPy array functions written in C

https://github.com/pydata/bottleneck

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    7 of 34 committers (20.6%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (4.3%) to scientific vocabulary

Keywords

c c-extension fast numpy python

Keywords from Contributors

alignment flexible closember gtk qt tk wx tensor astronomy astrophysics
Last synced: 6 months ago · JSON representation

Repository

Fast NumPy array functions written in C

Basic Info
  • Host: GitHub
  • Owner: pydata
  • License: bsd-2-clause
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 12.9 MB
Statistics
  • Stars: 1,135
  • Watchers: 34
  • Forks: 110
  • Open Issues: 46
  • Releases: 4
Topics
c c-extension fast numpy python
Created about 15 years ago · Last pushed 6 months ago
Metadata Files
Readme License

README.rst

.. image:: https://github.com/pydata/bottleneck/workflows/Github%20Actions/badge.svg
    :target: https://github.com/pydata/bottleneck/actions

==========
Bottleneck
==========

Bottleneck is a collection of fast NumPy array functions written in C.

Let's give it a try. Create a NumPy array:

.. code-block:: pycon

    >>> import numpy as np
    >>> a = np.array([1, 2, np.nan, 4, 5])

Find the nanmean:

.. code-block:: pycon

    >>> import bottleneck as bn
    >>> bn.nanmean(a)
    3.0

Moving window mean:

.. code-block:: pycon

    >>> bn.move_mean(a, window=2, min_count=1)
    array([ 1. ,  1.5,  2. ,  4. ,  4.5])

Benchmark
=========

Bottleneck comes with a benchmark suite:

.. code-block:: pycon

    >>> bn.bench()
    Bottleneck performance benchmark
        Bottleneck 1.3.0.dev0+122.gb1615d7; Numpy 1.16.4
        Speed is NumPy time divided by Bottleneck time
        NaN means approx one-fifth NaNs; float64 used

                  no NaN     no NaN      NaN       no NaN      NaN
                   (100,)  (1000,1000)(1000,1000)(1000,1000)(1000,1000)
                   axis=0     axis=0     axis=0     axis=1     axis=1
    nansum         29.7        1.4        1.6        2.0        2.1
    nanmean        99.0        2.0        1.8        3.2        2.5
    nanstd        145.6        1.8        1.8        2.7        2.5
    nanvar        138.4        1.8        1.8        2.8        2.5
    nanmin         27.6        0.5        1.7        0.7        2.4
    nanmax         26.6        0.6        1.6        0.7        2.5
    median        120.6        1.3        4.9        1.1        5.7
    nanmedian     117.8        5.0        5.7        4.8        5.5
    ss             13.2        1.2        1.3        1.5        1.5
    nanargmin      66.8        5.5        4.8        3.5        7.1
    nanargmax      57.6        2.9        5.1        2.5        5.3
    anynan         10.2        0.3       52.3        0.8       41.6
    allnan         15.1      196.0      156.3      135.8      111.2
    rankdata       45.9        1.2        1.2        2.1        2.1
    nanrankdata    50.5        1.4        1.3        2.4        2.3
    partition       3.3        1.1        1.6        1.0        1.5
    argpartition    3.4        1.2        1.5        1.1        1.6
    replace         9.0        1.5        1.5        1.5        1.5
    push         1565.6        5.9        7.0       13.0       10.9
    move_sum     2159.3       31.1       83.6      186.9      182.5
    move_mean    6264.3       66.2      111.9      361.1      246.5
    move_std     8653.6       86.5      163.7      232.0      317.7
    move_var     8856.0       96.3      171.6      267.9      332.9
    move_min     1186.6       13.4       30.9       23.5       45.0
    move_max     1188.0       14.6       29.9       23.5       46.0
    move_argmin  2568.3       33.3       61.0       49.2       86.8
    move_argmax  2475.8       30.9       58.6       45.0       82.8
    move_median  2236.9      153.9      151.4      171.3      166.9
    move_rank     847.1        1.2        1.4        2.3        2.6

You can also run a detailed benchmark for a single function using, for
example, the command:

.. code-block:: pycon

    >>> bn.bench_detailed("move_median", fraction_nan=0.3)

Only arrays with data type (dtype) int32, int64, float32, and float64 are
accelerated. All other dtypes result in calls to slower, unaccelerated
functions. In the rare case of a byte-swapped input array (e.g. a big-endian
array on a little-endian operating system) the function will not be
accelerated regardless of dtype.

Where
=====

===================   ========================================================
 download             https://pypi.python.org/pypi/Bottleneck
 docs                 https://bottleneck.readthedocs.io
 code                 https://github.com/pydata/bottleneck
 mailing list         https://groups.google.com/group/bottle-neck
===================   ========================================================

License
=======

Bottleneck is distributed under a Simplified BSD license. See the LICENSE file
and LICENSES directory for details.

Install
=======

Bottleneck provides binary wheels on PyPI for all the most common platforms.
Binary packages are also available in conda-forge. We recommend installing binaries
with ``pip``, ``uv``, ``conda`` or similar - it's faster and easier than building
from source.

Installing from source
----------------------

Requirements:

======================== ============================================================================
Bottleneck               Python >=3.9; NumPy 1.16.0+
Compile                  gcc, clang, MinGW or MSVC
Unit tests               pytest
Documentation            sphinx, numpydoc
======================== ============================================================================

To install Bottleneck on Linux, Mac OS X, et al.:

.. code-block:: console

    $ pip install .

To install bottleneck on Windows, first install MinGW and add it to your
system path. Then install Bottleneck with the command:

.. code-block:: console

    $ python setup.py install --compiler=mingw32

Unit tests
==========

After you have installed Bottleneck, run the suite of unit tests:

.. code-block:: pycon

  In [1]: import bottleneck as bn

  In [2]: bn.test()
  ============================= test session starts =============================
  platform linux -- Python 3.7.4, pytest-4.3.1, py-1.8.0, pluggy-0.12.0
  hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/chris/code/bottleneck/.hypothesis/examples')
  rootdir: /home/chris/code/bottleneck, inifile: setup.cfg
  plugins: openfiles-0.3.2, remotedata-0.3.2, doctestplus-0.3.0, mock-1.10.4, forked-1.0.2, cov-2.7.1, hypothesis-4.32.2, xdist-1.26.1, arraydiff-0.3
  collected 190 items
  
  bottleneck/tests/input_modification_test.py ........................... [ 14%]
  ..                                                                      [ 15%]
  bottleneck/tests/list_input_test.py .............................       [ 30%]
  bottleneck/tests/move_test.py .................................         [ 47%]
  bottleneck/tests/nonreduce_axis_test.py ....................            [ 58%]
  bottleneck/tests/nonreduce_test.py ..........                           [ 63%]
  bottleneck/tests/reduce_test.py ....................................... [ 84%]
  ............                                                            [ 90%]
  bottleneck/tests/scalar_input_test.py ..................                [100%]
  
  ========================= 190 passed in 46.42 seconds =========================
  Out[2]: True

If developing in the git repo, simply run ``py.test``

Owner

  • Name: Python for Data
  • Login: pydata
  • Kind: organization

GitHub Events

Total
  • Create event: 5
  • Commit comment event: 5
  • Issues event: 21
  • Watch event: 71
  • Member event: 1
  • Issue comment event: 68
  • Push event: 14
  • Pull request review comment event: 12
  • Pull request review event: 11
  • Pull request event: 27
  • Fork event: 9
Last Year
  • Create event: 5
  • Commit comment event: 5
  • Issues event: 21
  • Watch event: 71
  • Member event: 1
  • Issue comment event: 68
  • Push event: 14
  • Pull request review comment event: 12
  • Pull request review event: 11
  • Pull request event: 27
  • Fork event: 9

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 1,233
  • Total Committers: 34
  • Avg Commits per committer: 36.265
  • Development Distribution Score (DDS): 0.311
Past Year
  • Commits: 18
  • Committers: 3
  • Avg Commits per committer: 6.0
  • Development Distribution Score (DDS): 0.444
Top Committers
Name Email Commits
Keith Goodman k****n@g****m 849
Christopher Whelan t****n@g****m 229
Moritz E. Beber m****r@p****t 27
Ruben Di Battista r****a@g****m 27
Pietro Battiston me@p****t 15
Stephan Hoyer s****r@c****m 14
Dougal Sutherland d****l@g****m 12
Ralf Gommers r****s@g****m 10
Jenn Olsen j****4@g****m 7
Santiago Castro s****o@u****u 6
Lev Givon l****v@c****u 5
Christoph Gohlke c****e@u****u 4
Thomas Robitaille t****e@g****m 3
Jaime Fernandez j****o@g****m 2
Gábor Lipták g****k@g****m 2
Michał Górny m****y@g****g 2
Ruben DI BATTISTA r****a@q****m 2
odidev o****v@p****m 1
jmcloughlin J****n@b****m 1
Victor Stinner v****r@p****g 1
RichardScottOZ 7****Z 1
Nilesh Patra n****h@n****o 1
Mathias Hauser m****r@e****h 1
Martin K. Scherer m****r@f****e 1
John Benediktsson m****7@g****m 1
Jens Hedegaard Nielsen j****n@u****k 1
Ghislain Antony Vaillant g****l 1
Edgar Andrés Margffoy Tuay a****y@g****m 1
Daniel Hakimi D****i@g****m 1
Chris Burroughs c****s@g****m 1
and 4 more...

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 68
  • Total pull requests: 104
  • Average time to close issues: over 1 year
  • Average time to close pull requests: about 2 months
  • Total issue authors: 64
  • Total pull request authors: 25
  • Average comments per issue: 4.24
  • Average comments per pull request: 1.37
  • Merged pull requests: 76
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 11
  • Pull requests: 27
  • Average time to close issues: 2 months
  • Average time to close pull requests: 17 days
  • Issue authors: 10
  • Pull request authors: 4
  • Average comments per issue: 1.73
  • Average comments per pull request: 1.67
  • Merged pull requests: 20
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • jkadbear (2)
  • rgommers (2)
  • RubendeBruin (2)
  • sysy007uuu (2)
  • ctwardy (1)
  • veenstrajelmer (1)
  • hpretl (1)
  • wukan1986 (1)
  • astrojuanlu (1)
  • Snape3058 (1)
  • bscully27 (1)
  • Kinzowa (1)
  • parmar652 (1)
  • cwiede (1)
  • OutSquareCapital (1)
Pull Request Authors
  • rdbisme (28)
  • qwhelan (26)
  • rgommers (18)
  • astrofrog (3)
  • stonebig (3)
  • bnavigator (2)
  • cburroughs (2)
  • itsjohnward (2)
  • andfoy (2)
  • gliptak (2)
  • mark-thm (2)
  • lusewell (1)
  • nileshpatra (1)
  • wukan1986 (1)
  • andrii-riazanov (1)
Top Labels
Issue Labels
bug (39) packaging (4) enhancement (1)
Pull Request Labels
packaging (7) enhancement (1)

Packages

  • Total packages: 5
  • Total downloads:
    • pypi 3,932,046 last-month
  • Total docker downloads: 360
  • Total dependent packages: 190
    (may contain duplicates)
  • Total dependent repositories: 2,967
    (may contain duplicates)
  • Total versions: 106
  • Total maintainers: 4
pypi.org: bottleneck

Fast NumPy array functions written in C

  • Versions: 52
  • Dependent Packages: 130
  • Dependent Repositories: 1,023
  • Downloads: 3,932,046 Last month
  • Docker Downloads: 360
Rankings
Dependent packages count: 0.1%
Dependent repos count: 0.4%
Downloads: 0.4%
Average: 1.7%
Stargazers count: 2.1%
Docker downloads count: 2.5%
Forks count: 4.6%
Maintainers (3)
Last synced: 6 months ago
spack.io: py-bottleneck

A collection of fast NumPy array functions written in Cython.

  • Versions: 9
  • Dependent Packages: 5
  • Dependent Repositories: 0
Rankings
Dependent repos count: 0.0%
Average: 5.8%
Dependent packages count: 11.6%
Maintainers (1)
Last synced: 6 months ago
proxy.golang.org: github.com/pydata/bottleneck
  • Versions: 28
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Stargazers count: 2.1%
Forks count: 2.6%
Average: 6.3%
Dependent packages count: 9.6%
Dependent repos count: 10.8%
Last synced: 6 months ago
conda-forge.org: bottleneck

Bottleneck is a collection of fast NumPy array functions written in Cython.

  • Versions: 10
  • Dependent Packages: 46
  • Dependent Repositories: 972
Rankings
Dependent repos count: 0.8%
Dependent packages count: 1.5%
Average: 8.7%
Stargazers count: 13.5%
Forks count: 18.8%
Last synced: 6 months ago
anaconda.org: bottleneck

Bottleneck is a collection of fast NumPy array functions written in Cython.

  • Versions: 7
  • Dependent Packages: 9
  • Dependent Repositories: 972
Rankings
Dependent repos count: 4.7%
Dependent packages count: 4.9%
Average: 16.5%
Stargazers count: 24.7%
Forks count: 31.7%
Last synced: 6 months ago

Dependencies

setup.py pypi
  • numpy *
.github/workflows/ci.yml actions
  • actions/checkout v2 composite
  • actions/checkout v3 composite
  • actions/download-artifact v3 composite
  • actions/setup-python v2 composite
  • actions/upload-artifact v3 composite
  • pypa/cibuildwheel v2.7.0 composite
  • pypa/gh-action-pypi-publish v1.5.0 composite
bottleneck/tests/docker/centos_7_min_deps/Dockerfile docker
  • centos 7 build
bottleneck/tests/docker/centos_8_min_deps/Dockerfile docker
  • centos 8 build
bottleneck/tests/docker/ubuntu_devel_min_deps/Dockerfile docker
  • ubuntu devel build
bottleneck/tests/docker/ubuntu_lts_min_deps/Dockerfile docker
  • ubuntu latest build