| 1 |
Metadata-Version: 2.1 |
| 2 |
Name: Bottleneck |
| 3 |
Version: 1.4.2 |
| 4 |
Summary: Fast NumPy array functions written in C |
| 5 |
Home-page: https://github.com/pydata/bottleneck |
| 6 |
Download-URL: http://pypi.python.org/pypi/Bottleneck |
| 7 |
Maintainer: Christopher Whelan |
| 8 |
Maintainer-email: [email protected] |
| 9 |
License: Simplified BSD |
| 10 |
Platform: OS Independent |
| 11 |
Classifier: Development Status :: 5 - Production/Stable |
| 12 |
Classifier: Environment :: Console |
| 13 |
Classifier: Intended Audience :: Science/Research |
| 14 |
Classifier: Intended Audience :: Financial and Insurance Industry |
| 15 |
Classifier: License :: OSI Approved :: BSD License |
| 16 |
Classifier: Operating System :: OS Independent |
| 17 |
Classifier: Programming Language :: C |
| 18 |
Classifier: Programming Language :: Python |
| 19 |
Classifier: Programming Language :: Python :: 3 |
| 20 |
Classifier: Programming Language :: Python :: 3.9 |
| 21 |
Classifier: Programming Language :: Python :: 3.10 |
| 22 |
Classifier: Programming Language :: Python :: 3.11 |
| 23 |
Classifier: Programming Language :: Python :: 3.12 |
| 24 |
Classifier: Programming Language :: Python :: 3.13 |
| 25 |
Classifier: Topic :: Scientific/Engineering |
| 26 |
Requires-Python: >=3.9 |
| 27 |
Description-Content-Type: text/x-rst |
| 28 |
License-File: LICENSE |
| 29 |
Requires-Dist: numpy |
| 30 |
Provides-Extra: doc |
| 31 |
Requires-Dist: numpydoc; extra == "doc" |
| 32 |
Requires-Dist: sphinx; extra == "doc" |
| 33 |
Requires-Dist: gitpython; extra == "doc" |
| 34 |
|
| 35 |
Bottleneck is a collection of fast NumPy array functions written in C. |
| 36 |
|
| 37 |
Let's give it a try. Create a NumPy array: |
| 38 |
|
| 39 |
.. code-block:: pycon |
| 40 |
|
| 41 |
>>> import numpy as np |
| 42 |
>>> a = np.array([1, 2, np.nan, 4, 5]) |
| 43 |
|
| 44 |
Find the nanmean: |
| 45 |
|
| 46 |
.. code-block:: pycon |
| 47 |
|
| 48 |
>>> import bottleneck as bn |
| 49 |
>>> bn.nanmean(a) |
| 50 |
3.0 |
| 51 |
|
| 52 |
Moving window mean: |
| 53 |
|
| 54 |
.. code-block:: pycon |
| 55 |
|
| 56 |
>>> bn.move_mean(a, window=2, min_count=1) |
| 57 |
array([ 1. , 1.5, 2. , 4. , 4.5]) |
| 58 |
|
| 59 |
Benchmark |
| 60 |
========= |
| 61 |
|
| 62 |
Bottleneck comes with a benchmark suite: |
| 63 |
|
| 64 |
.. code-block:: pycon |
| 65 |
|
| 66 |
>>> bn.bench() |
| 67 |
Bottleneck performance benchmark |
| 68 |
Bottleneck 1.3.0.dev0+122.gb1615d7; Numpy 1.16.4 |
| 69 |
Speed is NumPy time divided by Bottleneck time |
| 70 |
NaN means approx one-fifth NaNs; float64 used |
| 71 |
|
| 72 |
no NaN no NaN NaN no NaN NaN |
| 73 |
(100,) (1000,1000)(1000,1000)(1000,1000)(1000,1000) |
| 74 |
axis=0 axis=0 axis=0 axis=1 axis=1 |
| 75 |
nansum 29.7 1.4 1.6 2.0 2.1 |
| 76 |
nanmean 99.0 2.0 1.8 3.2 2.5 |
| 77 |
nanstd 145.6 1.8 1.8 2.7 2.5 |
| 78 |
nanvar 138.4 1.8 1.8 2.8 2.5 |
| 79 |
nanmin 27.6 0.5 1.7 0.7 2.4 |
| 80 |
nanmax 26.6 0.6 1.6 0.7 2.5 |
| 81 |
median 120.6 1.3 4.9 1.1 5.7 |
| 82 |
nanmedian 117.8 5.0 5.7 4.8 5.5 |
| 83 |
ss 13.2 1.2 1.3 1.5 1.5 |
| 84 |
nanargmin 66.8 5.5 4.8 3.5 7.1 |
| 85 |
nanargmax 57.6 2.9 5.1 2.5 5.3 |
| 86 |
anynan 10.2 0.3 52.3 0.8 41.6 |
| 87 |
allnan 15.1 196.0 156.3 135.8 111.2 |
| 88 |
rankdata 45.9 1.2 1.2 2.1 2.1 |
| 89 |
nanrankdata 50.5 1.4 1.3 2.4 2.3 |
| 90 |
partition 3.3 1.1 1.6 1.0 1.5 |
| 91 |
argpartition 3.4 1.2 1.5 1.1 1.6 |
| 92 |
replace 9.0 1.5 1.5 1.5 1.5 |
| 93 |
push 1565.6 5.9 7.0 13.0 10.9 |
| 94 |
move_sum 2159.3 31.1 83.6 186.9 182.5 |
| 95 |
move_mean 6264.3 66.2 111.9 361.1 246.5 |
| 96 |
move_std 8653.6 86.5 163.7 232.0 317.7 |
| 97 |
move_var 8856.0 96.3 171.6 267.9 332.9 |
| 98 |
move_min 1186.6 13.4 30.9 23.5 45.0 |
| 99 |
move_max 1188.0 14.6 29.9 23.5 46.0 |
| 100 |
move_argmin 2568.3 33.3 61.0 49.2 86.8 |
| 101 |
move_argmax 2475.8 30.9 58.6 45.0 82.8 |
| 102 |
move_median 2236.9 153.9 151.4 171.3 166.9 |
| 103 |
move_rank 847.1 1.2 1.4 2.3 2.6 |
| 104 |
|
| 105 |
You can also run a detailed benchmark for a single function using, for |
| 106 |
example, the command: |
| 107 |
|
| 108 |
.. code-block:: pycon |
| 109 |
|
| 110 |
>>> bn.bench_detailed("move_median", fraction_nan=0.3) |
| 111 |
|
| 112 |
Only arrays with data type (dtype) int32, int64, float32, and float64 are |
| 113 |
accelerated. All other dtypes result in calls to slower, unaccelerated |
| 114 |
functions. In the rare case of a byte-swapped input array (e.g. a big-endian |
| 115 |
array on a little-endian operating system) the function will not be |
| 116 |
accelerated regardless of dtype. |
| 117 |
|
| 118 |
Where |
| 119 |
===== |
| 120 |
|
| 121 |
=================== ======================================================== |
| 122 |
download https://pypi.python.org/pypi/Bottleneck |
| 123 |
docs https://bottleneck.readthedocs.io |
| 124 |
code https://github.com/pydata/bottleneck |
| 125 |
mailing list https://groups.google.com/group/bottle-neck |
| 126 |
=================== ======================================================== |
| 127 |
|
| 128 |
License |
| 129 |
======= |
| 130 |
|
| 131 |
Bottleneck is distributed under a Simplified BSD license. See the LICENSE file |
| 132 |
and LICENSES directory for details. |
| 133 |
|
| 134 |
Install |
| 135 |
======= |
| 136 |
|
| 137 |
Requirements: |
| 138 |
|
| 139 |
======================== ============================================================================ |
| 140 |
Bottleneck Python 2.7, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10, 3.11; NumPy 1.16.0+ |
| 141 |
Compile gcc, clang, MinGW or MSVC |
| 142 |
Unit tests pytest |
| 143 |
Documentation sphinx, numpydoc |
| 144 |
======================== ============================================================================ |
| 145 |
|
| 146 |
To install Bottleneck on Linux, Mac OS X, et al.: |
| 147 |
|
| 148 |
.. code-block:: console |
| 149 |
|
| 150 |
$ pip install . |
| 151 |
|
| 152 |
To install bottleneck on Windows, first install MinGW and add it to your |
| 153 |
system path. Then install Bottleneck with the command: |
| 154 |
|
| 155 |
.. code-block:: console |
| 156 |
|
| 157 |
$ python setup.py install --compiler=mingw32 |
| 158 |
|
| 159 |
Alternatively, you can use the Windows binaries created by Christoph Gohlke: |
| 160 |
http://www.lfd.uci.edu/~gohlke/pythonlibs/#bottleneck |
| 161 |
|
| 162 |
Unit tests |
| 163 |
========== |
| 164 |
|
| 165 |
After you have installed Bottleneck, run the suite of unit tests: |
| 166 |
|
| 167 |
.. code-block:: pycon |
| 168 |
|
| 169 |
In [1]: import bottleneck as bn |
| 170 |
|
| 171 |
In [2]: bn.test() |
| 172 |
============================= test session starts ============================= |
| 173 |
platform linux -- Python 3.7.4, pytest-4.3.1, py-1.8.0, pluggy-0.12.0 |
| 174 |
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('/home/chris/code/bottleneck/.hypothesis/examples') |
| 175 |
rootdir: /home/chris/code/bottleneck, inifile: setup.cfg |
| 176 |
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 |
| 177 |
collected 190 items |
| 178 |
|
| 179 |
bottleneck/tests/input_modification_test.py ........................... [ 14%] |
| 180 |
.. [ 15%] |
| 181 |
bottleneck/tests/list_input_test.py ............................. [ 30%] |
| 182 |
bottleneck/tests/move_test.py ................................. [ 47%] |
| 183 |
bottleneck/tests/nonreduce_axis_test.py .................... [ 58%] |
| 184 |
bottleneck/tests/nonreduce_test.py .......... [ 63%] |
| 185 |
bottleneck/tests/reduce_test.py ....................................... [ 84%] |
| 186 |
............ [ 90%] |
| 187 |
bottleneck/tests/scalar_input_test.py .................. [100%] |
| 188 |
|
| 189 |
========================= 190 passed in 46.42 seconds ========================= |
| 190 |
Out[2]: True |
| 191 |
|
| 192 |
If developing in the git repo, simply run ``py.test`` |