fast-histogram-0.9/0000755000175100001660000000000013662557242014617 5ustar vstsdocker00000000000000fast-histogram-0.9/.gitignore0000644000175100001660000000142713662557224016613 0ustar vstsdocker00000000000000# Compiled files *.py[cod] *.a *.o *.so *.pyd __pycache__ # Ignore .c files by default to avoid including generated code. If you want to # add a non-generated .c extension, use `git add -f filename.c`. *.c # Other generated files MANIFEST astropy/version.py astropy/cython_version.py astropy/wcs/include/wcsconfig.h astropy/_erfa/core.py astropy/_erfa/core.pyx # Sphinx _build _generated docs/api docs/generated docs/visualization/ngc6976.jpeg docs/visualization/ngc6976-default.jpeg # Packages/installer info *.egg *.egg-info dist build eggs .eggs parts bin var sdist develop-eggs .installed.cfg distribute-*.tar.gz # Other .cache .tox .*.swp .*.swo *~ .project .pydevproject .settings .coverage cover htmlcov # Mac OSX .DS_Store # PyCharm .idea .tox .tmp fast_histogram/version.py fast-histogram-0.9/CHANGES.rst0000644000175100001660000000301613662557224016421 0ustar vstsdocker000000000000000.9 (2020-05-24) ---------------- - Fixed a bug that caused incorrect results in the weighted 1-d histogram and the weighted and unweighted 2-d histogram functions if using arrays with different layouts in memory. [#52] 0.8 (2020-01-07) ---------------- - Fixed compatibility of test suite with latest version of the hypothesis package. [#40] 0.7 (2019-01-09) ---------------- - Fix definition of numpy as a build-time dependency. [#36] 0.6 (2019-01-07) ---------------- - Define numpy as a build-time dependency in pyproject.toml. [#33] - Release the GIL during calculations in C code. [#31] 0.5 (2018-09-26) ---------------- - Fix bug that caused histograms of n-dimensional arrays to not be computed correctly. [#21] - Avoid memory copies for non-native endian 64-bit float arrays. [#18] - Avoid memory copies for any numerical Numpy type and non-contiguous arrays. [#23] - Raise a better error if arrays are passed to the ``bins`` argument. [#24] 0.4 (2018-02-12) ---------------- - Make sure that Numpy is not required to run setup.py. [#15] - Fix installation on platforms with an ASCII locale. [#15] 0.3 (2017-10-28) ---------------- - Use long instead of int for x/y sizes and indices - Implement support for weights= option 0.2.1 (2017-07-18) ------------------ - Fixed rst syntax in README 0.2 (2017-07-18) ---------------- - Fixed segmentation fault under certain conditions. - Ensure that arrays are C-contiguous before passing them to the C code. 0.1 (2017-07-18) ---------------- - Initial version fast-histogram-0.9/LICENSE0000644000175100001660000000242313662557224015625 0ustar vstsdocker00000000000000Copyright (c) 2017, Thomas P. Robitaille All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. fast-histogram-0.9/MANIFEST.in0000644000175100001660000000011613662557224016353 0ustar vstsdocker00000000000000include LICENSE include README.rst include CHANGES.rst include pyproject.toml fast-histogram-0.9/PKG-INFO0000644000175100001660000001725413662557242015725 0ustar vstsdocker00000000000000Metadata-Version: 2.1 Name: fast-histogram Version: 0.9 Summary: Fast simple 1D and 2D histograms Home-page: https://github.com/astrofrog/fast-histogram Author: Thomas Robitaille Author-email: thomas.robitaille@gmail.com License: BSD Description: |Azure Status| |asv| About ----- Sometimes you just want to compute simple 1D or 2D histograms with regular bins. Fast. No nonsense. `Numpy's `__ histogram functions are versatile, and can handle for example non-regular binning, but this versatility comes at the expense of performance. The **fast-histogram** mini-package aims to provide simple and fast histogram functions for regular bins that don't compromise on performance. It doesn't do anything complicated - it just implements a simple histogram algorithm in C and keeps it simple. The aim is to have functions that are fast but also robust and reliable. The result is a 1D histogram function here that is **7-15x faster** than ``numpy.histogram``, and a 2D histogram function that is **20-25x faster** than ``numpy.histogram2d``. To install:: pip install fast-histogram or if you use conda you can instead do:: conda install -c conda-forge fast-histogram The ``fast_histogram`` module then provides two functions: ``histogram1d`` and ``histogram2d``: .. code:: python from fast_histogram import histogram1d, histogram2d Example ------- Here's an example of binning 10 million points into a regular 2D histogram: .. code:: python In [1]: import numpy as np In [2]: x = np.random.random(10_000_000) In [3]: y = np.random.random(10_000_000) In [4]: %timeit _ = np.histogram2d(x, y, range=[[-1, 2], [-2, 4]], bins=30) 935 ms ± 58.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each) In [5]: from fast_histogram import histogram2d In [6]: %timeit _ = histogram2d(x, y, range=[[-1, 2], [-2, 4]], bins=30) 40.2 ms ± 624 µs per loop (mean ± std. dev. of 7 runs, 10 loops each) (note that ``10_000_000`` is possible in Python 3.6 syntax, use ``10000000`` instead in previous versions) The version here is over 20 times faster! The following plot shows the speedup as a function of array size for the bin parameters shown above: .. figure:: https://github.com/astrofrog/fast-histogram/raw/master/speedup_compared.png :alt: Comparison of performance between Numpy and fast-histogram as well as results for the 1D case, also with 30 bins. The speedup for the 2D case is consistently between 20-25x, and for the 1D case goes from 15x for small arrays to around 7x for large arrays. Q&A --- Why don't the histogram functions return the edges? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Computing and returning the edges may seem trivial but it can slow things down by a factor of a few when computing histograms of 10^5 or fewer elements, so not returning the edges is a deliberate decision related to performance. You can easily compute the edges yourself if needed though, using ``numpy.linspace``. Doesn't package X already do this, but better? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This may very well be the case! If this duplicates another package, or if it is possible to use Numpy in a smarter way to get the same performance gains, please open an issue and I'll consider deprecating this package :) One package that does include fast histogram functions (including in n-dimensions) and can compute other statistics is `vaex `_, so take a look there if you need more advanced functionality! Are the 2D histograms not transposed compared to what they should be? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There is technically no 'right' and 'wrong' orientation - here we adopt the convention which gives results consistent with Numpy, so: .. code:: python numpy.histogram2d(x, y, range=[[xmin, xmax], [ymin, ymax]], bins=[nx, ny]) should give the same result as: .. code:: python fast_histogram.histogram2d(x, y, range=[[xmin, xmax], [ymin, ymax]], bins=[nx, ny]) Why not contribute this to Numpy directly? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ As mentioned above, the Numpy functions are much more versatile, so they could not be replaced by the ones here. One option would be to check in Numpy's functions for cases that are simple and dispatch to functions such as the ones here, or add dedicated functions for regular binning. I hope we can get this in Numpy in some form or another eventually, but for now, the aim is to have this available to packages that need to support a range of Numpy versions. Why not use Cython? ~~~~~~~~~~~~~~~~~~~ I originally implemented this in Cython, but found that I could get a 50% performance improvement by going straight to a C extension. What about using Numba? ~~~~~~~~~~~~~~~~~~~~~~~ I specifically want to keep this package as easy as possible to install, and while `Numba `__ is a great package, it is not trivial to install outside of Anaconda. Could this be parallelized? ~~~~~~~~~~~~~~~~~~~~~~~~~~~ This may benefit from parallelization under certain circumstances. The easiest solution might be to use OpenMP, but this won't work on all platforms, so it would need to be made optional. Couldn't you make it faster by using the GPU? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Almost certainly, though the aim here is to have an easily installable and portable package, and introducing GPUs is going to affect both of these. Why make a package specifically for this? This is a tiny amount of functionality ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Packages that need this could simply bundle their own C extension or Cython code to do this, but the main motivation for releasing this as a mini-package is to avoid making pure-Python packages into packages that require compilation just because of the need to compute fast histograms. Can I contribute? ~~~~~~~~~~~~~~~~~ Yes please! This is not meant to be a finished package, and I welcome pull request to improve things. .. |Azure Status| image:: https://dev.azure.com/thomasrobitaille/fast-histogram/_apis/build/status/astrofrog.fast-histogram?branchName=master :target: https://dev.azure.com/thomasrobitaille/fast-histogram/_build/latest?definitionId=13&branchName=master .. |asv| image:: https://img.shields.io/badge/benchmarked%20by-asv-brightgreen.svg :target: https://astrofrog.github.io/fast-histogram Platform: UNKNOWN Requires-Python: >=3.6 Provides-Extra: test fast-histogram-0.9/README.rst0000644000175100001660000001416613662557224016316 0ustar vstsdocker00000000000000|Azure Status| |asv| About ----- Sometimes you just want to compute simple 1D or 2D histograms with regular bins. Fast. No nonsense. `Numpy's `__ histogram functions are versatile, and can handle for example non-regular binning, but this versatility comes at the expense of performance. The **fast-histogram** mini-package aims to provide simple and fast histogram functions for regular bins that don't compromise on performance. It doesn't do anything complicated - it just implements a simple histogram algorithm in C and keeps it simple. The aim is to have functions that are fast but also robust and reliable. The result is a 1D histogram function here that is **7-15x faster** than ``numpy.histogram``, and a 2D histogram function that is **20-25x faster** than ``numpy.histogram2d``. To install:: pip install fast-histogram or if you use conda you can instead do:: conda install -c conda-forge fast-histogram The ``fast_histogram`` module then provides two functions: ``histogram1d`` and ``histogram2d``: .. code:: python from fast_histogram import histogram1d, histogram2d Example ------- Here's an example of binning 10 million points into a regular 2D histogram: .. code:: python In [1]: import numpy as np In [2]: x = np.random.random(10_000_000) In [3]: y = np.random.random(10_000_000) In [4]: %timeit _ = np.histogram2d(x, y, range=[[-1, 2], [-2, 4]], bins=30) 935 ms ± 58.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each) In [5]: from fast_histogram import histogram2d In [6]: %timeit _ = histogram2d(x, y, range=[[-1, 2], [-2, 4]], bins=30) 40.2 ms ± 624 µs per loop (mean ± std. dev. of 7 runs, 10 loops each) (note that ``10_000_000`` is possible in Python 3.6 syntax, use ``10000000`` instead in previous versions) The version here is over 20 times faster! The following plot shows the speedup as a function of array size for the bin parameters shown above: .. figure:: https://github.com/astrofrog/fast-histogram/raw/master/speedup_compared.png :alt: Comparison of performance between Numpy and fast-histogram as well as results for the 1D case, also with 30 bins. The speedup for the 2D case is consistently between 20-25x, and for the 1D case goes from 15x for small arrays to around 7x for large arrays. Q&A --- Why don't the histogram functions return the edges? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Computing and returning the edges may seem trivial but it can slow things down by a factor of a few when computing histograms of 10^5 or fewer elements, so not returning the edges is a deliberate decision related to performance. You can easily compute the edges yourself if needed though, using ``numpy.linspace``. Doesn't package X already do this, but better? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This may very well be the case! If this duplicates another package, or if it is possible to use Numpy in a smarter way to get the same performance gains, please open an issue and I'll consider deprecating this package :) One package that does include fast histogram functions (including in n-dimensions) and can compute other statistics is `vaex `_, so take a look there if you need more advanced functionality! Are the 2D histograms not transposed compared to what they should be? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There is technically no 'right' and 'wrong' orientation - here we adopt the convention which gives results consistent with Numpy, so: .. code:: python numpy.histogram2d(x, y, range=[[xmin, xmax], [ymin, ymax]], bins=[nx, ny]) should give the same result as: .. code:: python fast_histogram.histogram2d(x, y, range=[[xmin, xmax], [ymin, ymax]], bins=[nx, ny]) Why not contribute this to Numpy directly? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ As mentioned above, the Numpy functions are much more versatile, so they could not be replaced by the ones here. One option would be to check in Numpy's functions for cases that are simple and dispatch to functions such as the ones here, or add dedicated functions for regular binning. I hope we can get this in Numpy in some form or another eventually, but for now, the aim is to have this available to packages that need to support a range of Numpy versions. Why not use Cython? ~~~~~~~~~~~~~~~~~~~ I originally implemented this in Cython, but found that I could get a 50% performance improvement by going straight to a C extension. What about using Numba? ~~~~~~~~~~~~~~~~~~~~~~~ I specifically want to keep this package as easy as possible to install, and while `Numba `__ is a great package, it is not trivial to install outside of Anaconda. Could this be parallelized? ~~~~~~~~~~~~~~~~~~~~~~~~~~~ This may benefit from parallelization under certain circumstances. The easiest solution might be to use OpenMP, but this won't work on all platforms, so it would need to be made optional. Couldn't you make it faster by using the GPU? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Almost certainly, though the aim here is to have an easily installable and portable package, and introducing GPUs is going to affect both of these. Why make a package specifically for this? This is a tiny amount of functionality ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Packages that need this could simply bundle their own C extension or Cython code to do this, but the main motivation for releasing this as a mini-package is to avoid making pure-Python packages into packages that require compilation just because of the need to compute fast histograms. Can I contribute? ~~~~~~~~~~~~~~~~~ Yes please! This is not meant to be a finished package, and I welcome pull request to improve things. .. |Azure Status| image:: https://dev.azure.com/thomasrobitaille/fast-histogram/_apis/build/status/astrofrog.fast-histogram?branchName=master :target: https://dev.azure.com/thomasrobitaille/fast-histogram/_build/latest?definitionId=13&branchName=master .. |asv| image:: https://img.shields.io/badge/benchmarked%20by-asv-brightgreen.svg :target: https://astrofrog.github.io/fast-histogram fast-histogram-0.9/azure-pipelines.yml0000644000175100001660000000274413662557224020465 0ustar vstsdocker00000000000000resources: repositories: - repository: OpenAstronomy type: github endpoint: astrofrog name: OpenAstronomy/azure-pipelines-templates ref: master trigger: branches: include: - '*' tags: include: - 'v*' variables: CIBW_BUILD: cp36-* cp37-* cp38-* jobs: - template: run-tox-env.yml@OpenAstronomy parameters: coverage: codecov envs: - linux32: py36-test-numpy113 - linux32: py36-test-numpy114 - linux32: py36-test-numpy115 - linux32: py37-test-numpy116 - linux32: py37-test-numpy117 - linux32: py38-test-numpy118 - linux: py36-test-numpy113 - linux: py36-test-numpy114 - linux: py36-test-numpy115 - linux: py37-test-numpy116 - linux: py37-test-numpy117 - linux: py38-test-numpy118 - macos: py36-test-numpy113 - macos: py36-test-numpy114 - macos: py36-test-numpy115 - macos: py37-test-numpy116 - macos: py37-test-numpy117 - macos: py38-test-numpy118 - windows: py36-test-numpy113 - windows: py36-test-numpy114 - windows: py36-test-numpy115 - windows: py37-test-numpy116 - windows: py37-test-numpy117 - windows: py38-test-numpy118 - template: publish.yml@OpenAstronomy parameters: ${{ if startsWith(variables['Build.SourceBranch'], 'refs/tags/v') }}: pypi_connection_name: 'pypi_endpoint' test_extras: test test_command: pytest --pyargs fast_histogram targets: - sdist - wheels_linux - wheels_macos - wheels_windows fast-histogram-0.9/comparison/0000755000175100001660000000000013662557242016771 5ustar vstsdocker00000000000000fast-histogram-0.9/comparison/README.rst0000644000175100001660000000036413662557224020463 0ustar vstsdocker00000000000000About ----- The scripts in this directory are used to make the speedup_compared.png plot at the root of this repository. For more complete benchmarks, you can also visit our `asv benchmarks `_ page. fast-histogram-0.9/comparison/benchmark.py0000644000175100001660000000501113662557224021272 0ustar vstsdocker00000000000000# Script to compare the speedup provided by fast-histogram import numpy as np from timeit import timeit, repeat SETUP_1D = """ import numpy as np from numpy import histogram as np_histogram1d from fast_histogram import histogram1d x = np.random.random({size}) """ NUMPY_1D_STMT = "np_histogram1d(x, range=[-1, 2], bins=30)" FAST_1D_STMT = "histogram1d(x, range=[-1, 2], bins=30)" SETUP_2D = """ import numpy as np from numpy import histogram2d as np_histogram2d from fast_histogram import histogram2d x = np.random.random({size}) y = np.random.random({size}) """ NUMPY_2D_STMT = "np_histogram2d(x, y, range=[[-1, 2], [-2, 4]], bins=30)" FAST_2D_STMT = "histogram2d(x, y, range=[[-1, 2], [-2, 4]], bins=30)" # How long each benchmark should aim to take TARGET_TIME = 1.0 def time_stats(stmt=None, setup=None): # Call once to check how long it takes time_single = timeit(stmt=stmt, setup=setup, number=1) # Find out how many times we can call it. We always call it at least three # times for accuracy number = max(3, int(TARGET_TIME / time_single)) print(' -> estimated time to complete test: {0:.1f}s'.format(time_single * 10 * number)) times = repeat(stmt=stmt, setup=setup, repeat=10, number=number) return np.min(times) / number, np.mean(times) / number, np.median(times) / number FMT_HEADER = '# {:7s}' + ' {:10s}' * 12 + '\n' FMT = '{:9d}' + ' {:10.7e}' * 12 + '\n' with open('benchmark_times.txt', 'w') as f: f.write(FMT_HEADER.format('size', 'np_1d_min', 'np_1d_mean', 'np_1d_median', 'fa_1d_min', 'fa_1d_mean', 'fa_1d_median', 'np_2d_min', 'np_2d_mean', 'np_2d_median', 'fa_2d_min', 'fa_2d_mean', 'fa_2d_median')) for log10_size in range(0, 9): size = int(10 ** log10_size) print('Running benchmarks for size={0}'.format(size)) np_1d_min, np_1d_mean, np_1d_median = time_stats(stmt=NUMPY_1D_STMT, setup=SETUP_1D.format(size=size)) fa_1d_min, fa_1d_mean, fa_1d_median = time_stats(stmt=FAST_1D_STMT, setup=SETUP_1D.format(size=size)) np_2d_min, np_2d_mean, np_2d_median = time_stats(stmt=NUMPY_2D_STMT, setup=SETUP_2D.format(size=size)) fa_2d_min, fa_2d_mean, fa_2d_median = time_stats(stmt=FAST_2D_STMT, setup=SETUP_2D.format(size=size)) f.write(FMT.format(size, np_1d_min, np_1d_mean, np_1d_median, fa_1d_min, fa_1d_mean, fa_1d_median, np_2d_min, np_2d_mean, np_2d_median, fa_2d_min, fa_2d_mean, fa_2d_median)) f.flush() fast-histogram-0.9/comparison/plot.py0000644000175100001660000000137113662557224020323 0ustar vstsdocker00000000000000# Script to make the comparison plot for the benchmark import numpy as np import matplotlib.pyplot as plt (size, np_1d_min, np_1d_mean, np_1d_median, fa_1d_min, fa_1d_mean, fa_1d_median, np_2d_min, np_2d_mean, np_2d_median, fa_2d_min, fa_2d_mean, fa_2d_median) = np.loadtxt('benchmark_times.txt', unpack=True) fig = plt.figure() ax = fig.add_subplot(1, 1, 1) ax.plot(size, np_1d_min / fa_1d_min, color=(34 / 255, 122 / 255, 181 / 255), label='1D') ax.plot(size, np_2d_min / fa_2d_min, color=(255 / 255, 133 / 255, 25 / 255), label='2D') ax.set_xscale('log') ax.set_xlim(0.3, 3e8) ax.set_ylim(1, 35) ax.grid() ax.set_xlabel('Array size') ax.set_ylabel('Speedup (fast-histogram / numpy)') ax.legend() fig.savefig('speedup_compared.png', bbox_inches='tight') fast-histogram-0.9/fast_histogram/0000755000175100001660000000000013662557242017631 5ustar vstsdocker00000000000000fast-histogram-0.9/fast_histogram/__init__.py0000644000175100001660000000010513662557224021736 0ustar vstsdocker00000000000000from .histogram import * from .version import version as __version__ fast-histogram-0.9/fast_histogram/_histogram_core.c0000644000175100001660000004424313662557224023150 0ustar vstsdocker00000000000000#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION #include #include #include /* Define docstrings */ static char module_docstring[] = "Fast histogram functioins"; static char _histogram1d_docstring[] = "Compute a 1D histogram"; static char _histogram2d_docstring[] = "Compute a 2D histogram"; static char _histogram1d_weighted_docstring[] = "Compute a weighted 1D histogram"; static char _histogram2d_weighted_docstring[] = "Compute a weighted 2D histogram"; /* Declare the C functions here. */ static PyObject *_histogram1d(PyObject *self, PyObject *args); static PyObject *_histogram2d(PyObject *self, PyObject *args); static PyObject *_histogram1d_weighted(PyObject *self, PyObject *args); static PyObject *_histogram2d_weighted(PyObject *self, PyObject *args); /* Define the methods that will be available on the module. */ static PyMethodDef module_methods[] = { {"_histogram1d", _histogram1d, METH_VARARGS, _histogram1d_docstring}, {"_histogram2d", _histogram2d, METH_VARARGS, _histogram2d_docstring}, {"_histogram1d_weighted", _histogram1d_weighted, METH_VARARGS, _histogram1d_weighted_docstring}, {"_histogram2d_weighted", _histogram2d_weighted, METH_VARARGS, _histogram2d_weighted_docstring}, {NULL, NULL, 0, NULL} }; /* This is the function that is called on import. */ #if PY_MAJOR_VERSION >= 3 #define MOD_ERROR_VAL NULL #define MOD_SUCCESS_VAL(val) val #define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void) #define MOD_DEF(ob, name, doc, methods) \ static struct PyModuleDef moduledef = { \ PyModuleDef_HEAD_INIT, name, doc, -1, methods, }; \ ob = PyModule_Create(&moduledef); #else #define MOD_ERROR_VAL #define MOD_SUCCESS_VAL(val) #define MOD_INIT(name) void init##name(void) #define MOD_DEF(ob, name, doc, methods) \ ob = Py_InitModule3(name, methods, doc); #endif MOD_INIT(_histogram_core) { PyObject *m; MOD_DEF(m, "_histogram_core", module_docstring, module_methods); if (m == NULL) return MOD_ERROR_VAL; import_array(); return MOD_SUCCESS_VAL(m); } static PyObject *_histogram1d(PyObject *self, PyObject *args) { long n; int ix, nx; double xmin, xmax, tx, fnx, normx; PyObject *x_obj, *count_obj; PyArrayObject *x_array, *count_array; npy_intp dims[1]; double *count; NpyIter *iter; NpyIter_IterNextFunc *iternext; char **dataptr; npy_intp *strideptr, *innersizeptr; PyArray_Descr *dtype; /* Parse the input tuple */ if (!PyArg_ParseTuple(args, "Oidd", &x_obj, &nx, &xmin, &xmax)) { PyErr_SetString(PyExc_TypeError, "Error parsing input"); return NULL; } /* Interpret the input objects as `numpy` arrays. */ x_array = (PyArrayObject *)PyArray_FROM_O(x_obj); /* If that didn't work, throw an `Exception`. */ if (x_array == NULL) { PyErr_SetString(PyExc_TypeError, "Couldn't parse the input arrays."); Py_XDECREF(x_array); return NULL; } /* How many data points are there? */ n = (long)PyArray_DIM(x_array, 0); /* Build the output array */ dims[0] = nx; count_obj = PyArray_SimpleNew(1, dims, NPY_DOUBLE); if (count_obj == NULL) { PyErr_SetString(PyExc_RuntimeError, "Couldn't build output array"); Py_DECREF(x_array); Py_XDECREF(count_obj); return NULL; } count_array = (PyArrayObject *)count_obj; PyArray_FILLWBYTE(count_array, 0); if (n == 0) { Py_DECREF(x_array); return count_obj; } dtype = PyArray_DescrFromType(NPY_DOUBLE); iter = NpyIter_New(x_array, NPY_ITER_READONLY | NPY_ITER_EXTERNAL_LOOP | NPY_ITER_BUFFERED, NPY_KEEPORDER, NPY_SAFE_CASTING, dtype); if (iter == NULL) { PyErr_SetString(PyExc_RuntimeError, "Couldn't set up iterator"); Py_DECREF(x_array); Py_DECREF(count_obj); Py_DECREF(count_array); return NULL; } /* * The iternext function gets stored in a local variable * so it can be called repeatedly in an efficient manner. */ iternext = NpyIter_GetIterNext(iter, NULL); if (iternext == NULL) { PyErr_SetString(PyExc_RuntimeError, "Couldn't set up iterator"); NpyIter_Deallocate(iter); Py_DECREF(x_array); Py_DECREF(count_obj); Py_DECREF(count_array); return NULL; } /* The location of the data pointer which the iterator may update */ dataptr = NpyIter_GetDataPtrArray(iter); /* The location of the stride which the iterator may update */ strideptr = NpyIter_GetInnerStrideArray(iter); /* The location of the inner loop size which the iterator may update */ innersizeptr = NpyIter_GetInnerLoopSizePtr(iter); /* Pre-compute variables for efficiency in the histogram calculation */ fnx = nx; normx = 1. / (xmax - xmin); /* Get C array for output array */ count = (double *)PyArray_DATA(count_array); Py_BEGIN_ALLOW_THREADS do { /* Get the inner loop data/stride/count values */ npy_intp stride = *strideptr; npy_intp size = *innersizeptr; /* This is a typical inner loop for NPY_ITER_EXTERNAL_LOOP */ while (size--) { tx = *(double *)dataptr[0]; if (tx >= xmin && tx < xmax) { ix = (tx - xmin) * normx * fnx; count[ix] += 1.; } dataptr[0] += stride; } } while (iternext(iter)); Py_END_ALLOW_THREADS NpyIter_Deallocate(iter); /* Clean up. */ Py_DECREF(x_array); return count_obj; } static PyObject *_histogram2d(PyObject *self, PyObject *args) { long n; int ix, iy, nx, ny; double xmin, xmax, tx, fnx, normx, ymin, ymax, ty, fny, normy; PyObject *x_obj, *y_obj, *count_obj; PyArrayObject *x_array, *y_array, *count_array, *arrays[2]; npy_intp dims[2]; double *count; NpyIter *iter; NpyIter_IterNextFunc *iternext; char **dataptr; npy_intp *strideptr, *innersizeptr; PyArray_Descr *dtypes[] = {PyArray_DescrFromType(NPY_DOUBLE), PyArray_DescrFromType(NPY_DOUBLE)}; npy_uint32 op_flags[] = {NPY_ITER_READONLY, NPY_ITER_READONLY}; /* Parse the input tuple */ if (!PyArg_ParseTuple(args, "OOiddidd", &x_obj, &y_obj, &nx, &xmin, &xmax, &ny, &ymin, &ymax)) { PyErr_SetString(PyExc_TypeError, "Error parsing input"); return NULL; } /* Interpret the input objects as `numpy` arrays. */ x_array = (PyArrayObject *)PyArray_FROM_O(x_obj); y_array = (PyArrayObject *)PyArray_FROM_O(y_obj); /* If that didn't work, throw an `Exception`. */ if (x_array == NULL || y_array == NULL) { PyErr_SetString(PyExc_TypeError, "Couldn't parse the input arrays."); Py_XDECREF(x_array); Py_XDECREF(y_array); return NULL; } /* How many data points are there? */ n = (long)PyArray_DIM(x_array, 0); /* Check the dimensions. */ if (n != (long)PyArray_DIM(y_array, 0)) { PyErr_SetString(PyExc_RuntimeError, "Dimension mismatch between x and y"); Py_DECREF(x_array); Py_DECREF(y_array); return NULL; } /* Build the output array */ dims[0] = nx; dims[1] = ny; count_obj = PyArray_SimpleNew(2, dims, NPY_DOUBLE); if (count_obj == NULL) { PyErr_SetString(PyExc_RuntimeError, "Couldn't build output array"); Py_DECREF(x_array); Py_DECREF(y_array); Py_XDECREF(count_obj); return NULL; } count_array = (PyArrayObject *)count_obj; PyArray_FILLWBYTE(count_array, 0); if (n == 0) { Py_DECREF(x_array); Py_DECREF(y_array); return count_obj; } arrays[0] = x_array; arrays[1] = y_array; iter = NpyIter_AdvancedNew(2, arrays, NPY_ITER_EXTERNAL_LOOP | NPY_ITER_BUFFERED, NPY_KEEPORDER, NPY_SAFE_CASTING, op_flags, dtypes, -1, NULL, NULL, 0); if (iter == NULL) { PyErr_SetString(PyExc_RuntimeError, "Couldn't set up iterator"); Py_DECREF(x_array); Py_DECREF(y_array); Py_DECREF(count_obj); Py_DECREF(count_array); return NULL; } /* * The iternext function gets stored in a local variable * so it can be called repeatedly in an efficient manner. */ iternext = NpyIter_GetIterNext(iter, NULL); if (iternext == NULL) { PyErr_SetString(PyExc_RuntimeError, "Couldn't set up iterator"); NpyIter_Deallocate(iter); Py_DECREF(x_array); Py_DECREF(y_array); Py_DECREF(count_obj); Py_DECREF(count_array); return NULL; } /* The location of the data pointer which the iterator may update */ dataptr = NpyIter_GetDataPtrArray(iter); /* The location of the stride which the iterator may update */ strideptr = NpyIter_GetInnerStrideArray(iter); /* The location of the inner loop size which the iterator may update */ innersizeptr = NpyIter_GetInnerLoopSizePtr(iter); /* Pre-compute variables for efficiency in the histogram calculation */ fnx = nx; fny = ny; normx = 1. / (xmax - xmin); normy = 1. / (ymax - ymin); /* Get C array for output array */ count = (double *)PyArray_DATA(count_array); Py_BEGIN_ALLOW_THREADS do { /* Get the inner loop data/stride/count values */ npy_intp stride0 = strideptr[0]; npy_intp stride1 = strideptr[1]; npy_intp size = *innersizeptr; /* This is a typical inner loop for NPY_ITER_EXTERNAL_LOOP */ while (size--) { tx = *(double *)dataptr[0]; ty = *(double *)dataptr[1]; if (tx >= xmin && tx < xmax && ty >= ymin && ty < ymax) { ix = (tx - xmin) * normx * fnx; iy = (ty - ymin) * normy * fny; count[iy + ny * ix] += 1.; } dataptr[0] += stride0; dataptr[1] += stride1; } } while (iternext(iter)); Py_END_ALLOW_THREADS NpyIter_Deallocate(iter); /* Clean up. */ Py_DECREF(x_array); Py_DECREF(y_array); return count_obj; } static PyObject *_histogram1d_weighted(PyObject *self, PyObject *args) { long n; int ix, nx; double xmin, xmax, tx, tw, fnx, normx; PyObject *x_obj, *w_obj, *count_obj; PyArrayObject *x_array, *w_array, *count_array, *arrays[2]; npy_intp dims[1]; double *count; NpyIter *iter; NpyIter_IterNextFunc *iternext; char **dataptr; npy_intp *strideptr, *innersizeptr; PyArray_Descr *dtypes[] = {PyArray_DescrFromType(NPY_DOUBLE), PyArray_DescrFromType(NPY_DOUBLE)}; npy_uint32 op_flags[] = {NPY_ITER_READONLY, NPY_ITER_READONLY}; /* Parse the input tuple */ if (!PyArg_ParseTuple(args, "OOidd", &x_obj, &w_obj, &nx, &xmin, &xmax)) { PyErr_SetString(PyExc_TypeError, "Error parsing input"); return NULL; } /* Interpret the input objects as `numpy` arrays. */ x_array = (PyArrayObject *)PyArray_FROM_O(x_obj); w_array = (PyArrayObject *)PyArray_FROM_O(w_obj); /* If that didn't work, throw an `Exception`. */ if (x_array == NULL || w_array == NULL) { PyErr_SetString(PyExc_TypeError, "Couldn't parse the input arrays."); Py_XDECREF(x_array); Py_XDECREF(w_array); return NULL; } /* How many data points are there? */ n = (long)PyArray_DIM(x_array, 0); /* Check the dimensions. */ if (n != (long)PyArray_DIM(w_array, 0)) { PyErr_SetString(PyExc_RuntimeError, "Dimension mismatch between x and w"); Py_DECREF(x_array); Py_DECREF(w_array); return NULL; } /* Build the output array */ dims[0] = nx; count_obj = PyArray_SimpleNew(1, dims, NPY_DOUBLE); if (count_obj == NULL) { PyErr_SetString(PyExc_RuntimeError, "Couldn't build output array"); Py_DECREF(x_array); Py_DECREF(w_array); Py_XDECREF(count_obj); return NULL; } count_array = (PyArrayObject *)count_obj; PyArray_FILLWBYTE(count_array, 0); if (n == 0) { Py_DECREF(x_array); Py_DECREF(w_array); return count_obj; } arrays[0] = x_array; arrays[1] = w_array; iter = NpyIter_AdvancedNew(2, arrays, NPY_ITER_EXTERNAL_LOOP | NPY_ITER_BUFFERED, NPY_KEEPORDER, NPY_SAFE_CASTING, op_flags, dtypes, -1, NULL, NULL, 0); if (iter == NULL) { PyErr_SetString(PyExc_RuntimeError, "Couldn't set up iterator"); Py_DECREF(x_array); Py_DECREF(w_array); Py_DECREF(count_obj); Py_DECREF(count_array); return NULL; } /* * The iternext function gets stored in a local variable * so it can be called repeatedly in an efficient manner. */ iternext = NpyIter_GetIterNext(iter, NULL); if (iternext == NULL) { PyErr_SetString(PyExc_RuntimeError, "Couldn't set up iterator"); NpyIter_Deallocate(iter); Py_DECREF(x_array); Py_DECREF(w_array); Py_DECREF(count_obj); Py_DECREF(count_array); return NULL; } /* The location of the data pointer which the iterator may update */ dataptr = NpyIter_GetDataPtrArray(iter); /* The location of the stride which the iterator may update */ strideptr = NpyIter_GetInnerStrideArray(iter); /* The location of the inner loop size which the iterator may update */ innersizeptr = NpyIter_GetInnerLoopSizePtr(iter); /* Pre-compute variables for efficiency in the histogram calculation */ fnx = nx; normx = 1. / (xmax - xmin); /* Get C array for output array */ count = (double *)PyArray_DATA(count_array); Py_BEGIN_ALLOW_THREADS do { /* Get the inner loop data/stride/count values */ npy_intp stride0 = strideptr[0]; npy_intp stride1 = strideptr[1]; npy_intp size = *innersizeptr; /* This is a typical inner loop for NPY_ITER_EXTERNAL_LOOP */ while (size--) { tx = *(double *)dataptr[0]; tw = *(double *)dataptr[1]; if (tx >= xmin && tx < xmax) { ix = (tx - xmin) * normx * fnx; count[ix] += tw; } dataptr[0] += stride0; dataptr[1] += stride1; } } while (iternext(iter)); Py_END_ALLOW_THREADS NpyIter_Deallocate(iter); /* Clean up. */ Py_DECREF(x_array); Py_DECREF(w_array); return count_obj; } static PyObject *_histogram2d_weighted(PyObject *self, PyObject *args) { long n; int ix, iy, nx, ny; double xmin, xmax, tx, fnx, normx, ymin, ymax, ty, fny, normy, tw; PyObject *x_obj, *y_obj, *w_obj, *count_obj; PyArrayObject *x_array, *y_array, *w_array, *count_array, *arrays[3]; npy_intp dims[2]; double *count; NpyIter *iter; NpyIter_IterNextFunc *iternext; char **dataptr; npy_intp *strideptr, *innersizeptr; PyArray_Descr *dtypes[] = {PyArray_DescrFromType(NPY_DOUBLE), PyArray_DescrFromType(NPY_DOUBLE), PyArray_DescrFromType(NPY_DOUBLE)}; npy_uint32 op_flags[] = {NPY_ITER_READONLY, NPY_ITER_READONLY, NPY_ITER_READONLY}; /* Parse the input tuple */ if (!PyArg_ParseTuple(args, "OOOiddidd", &x_obj, &y_obj, &w_obj, &nx, &xmin, &xmax, &ny, &ymin, &ymax)) { PyErr_SetString(PyExc_TypeError, "Error parsing input"); return NULL; } /* Interpret the input objects as `numpy` arrays. */ x_array = (PyArrayObject *)PyArray_FROM_O(x_obj); y_array = (PyArrayObject *)PyArray_FROM_O(y_obj); w_array = (PyArrayObject *)PyArray_FROM_O(w_obj); /* If that didn't work, throw an `Exception`. */ if (x_array == NULL || y_array == NULL || w_array == NULL) { PyErr_SetString(PyExc_TypeError, "Couldn't parse the input arrays."); Py_XDECREF(x_array); Py_XDECREF(y_array); Py_XDECREF(w_array); return NULL; } /* How many data points are there? */ n = (long)PyArray_DIM(x_array, 0); /* Check the dimensions. */ if (n != (long)PyArray_DIM(y_array, 0) || n != (long)PyArray_DIM(w_array, 0)) { PyErr_SetString(PyExc_RuntimeError, "Dimension mismatch between x, y, and w"); Py_DECREF(x_array); Py_DECREF(y_array); Py_DECREF(w_array); return NULL; } /* Build the output array */ dims[0] = nx; dims[1] = ny; count_obj = PyArray_SimpleNew(2, dims, NPY_DOUBLE); if (count_obj == NULL) { PyErr_SetString(PyExc_RuntimeError, "Couldn't build output array"); Py_DECREF(x_array); Py_DECREF(y_array); Py_DECREF(w_array); Py_XDECREF(count_obj); return NULL; } count_array = (PyArrayObject *)count_obj; PyArray_FILLWBYTE(count_array, 0); if (n == 0) { Py_DECREF(x_array); Py_DECREF(y_array); Py_DECREF(w_array); return count_obj; } arrays[0] = x_array; arrays[1] = y_array; arrays[2] = w_array; iter = NpyIter_AdvancedNew(3, arrays, NPY_ITER_EXTERNAL_LOOP | NPY_ITER_BUFFERED, NPY_KEEPORDER, NPY_SAFE_CASTING, op_flags, dtypes, -1, NULL, NULL, 0); if (iter == NULL) { PyErr_SetString(PyExc_RuntimeError, "Couldn't set up iterator"); Py_DECREF(x_array); Py_DECREF(y_array); Py_DECREF(w_array); Py_DECREF(count_obj); Py_DECREF(count_array); return NULL; } /* * The iternext function gets stored in a local variable * so it can be called repeatedly in an efficient manner. */ iternext = NpyIter_GetIterNext(iter, NULL); if (iternext == NULL) { PyErr_SetString(PyExc_RuntimeError, "Couldn't set up iterator"); NpyIter_Deallocate(iter); Py_DECREF(x_array); Py_DECREF(y_array); Py_DECREF(w_array); Py_DECREF(count_obj); Py_DECREF(count_array); return NULL; } /* The location of the data pointer which the iterator may update */ dataptr = NpyIter_GetDataPtrArray(iter); /* The location of the stride which the iterator may update */ strideptr = NpyIter_GetInnerStrideArray(iter); /* The location of the inner loop size which the iterator may update */ innersizeptr = NpyIter_GetInnerLoopSizePtr(iter); /* Pre-compute variables for efficiency in the histogram calculation */ fnx = nx; fny = ny; normx = 1. / (xmax - xmin); normy = 1. / (ymax - ymin); /* Get C array for output array */ count = (double *)PyArray_DATA(count_array); Py_BEGIN_ALLOW_THREADS do { /* Get the inner loop data/stride/count values */ npy_intp stride0 = strideptr[0]; npy_intp stride1 = strideptr[1]; npy_intp stride2 = strideptr[2]; npy_intp size = *innersizeptr; /* This is a typical inner loop for NPY_ITER_EXTERNAL_LOOP */ while (size--) { tx = *(double *)dataptr[0]; ty = *(double *)dataptr[1]; tw = *(double *)dataptr[2]; if (tx >= xmin && tx < xmax && ty >= ymin && ty < ymax) { ix = (tx - xmin) * normx * fnx; iy = (ty - ymin) * normy * fny; count[iy + ny * ix] += tw; } dataptr[0] += stride0; dataptr[1] += stride1; dataptr[2] += stride2; } } while (iternext(iter)); Py_END_ALLOW_THREADS NpyIter_Deallocate(iter); /* Clean up. */ Py_DECREF(x_array); Py_DECREF(y_array); Py_DECREF(w_array); return count_obj; } fast-histogram-0.9/fast_histogram/histogram.py0000644000175100001660000000621513662557224022204 0ustar vstsdocker00000000000000from __future__ import division import numbers import numpy as np from ._histogram_core import (_histogram1d, _histogram2d, _histogram1d_weighted, _histogram2d_weighted) __all__ = ['histogram1d', 'histogram2d'] def histogram1d(x, bins, range, weights=None): """ Compute a 1D histogram assuming equally spaced bins. Parameters ---------- x : `~numpy.ndarray` The position of the points to bin in the 1D histogram bins : int The number of bins range : iterable The range as a tuple of (xmin, xmax) weights : `~numpy.ndarray` The weights of the points in the 1D histogram Returns ------- array : `~numpy.ndarray` The 1D histogram array """ nx = bins if not np.isscalar(bins): raise TypeError('bins should be an integer') xmin, xmax = range if not np.isfinite(xmin): raise ValueError("xmin should be finite") if not np.isfinite(xmax): raise ValueError("xmax should be finite") if xmax <= xmin: raise ValueError("xmax should be greater than xmin") if nx <= 0: raise ValueError("nx should be strictly positive") if weights is None: return _histogram1d(x, nx, xmin, xmax) else: return _histogram1d_weighted(x, weights, nx, xmin, xmax) def histogram2d(x, y, bins, range, weights=None): """ Compute a 2D histogram assuming equally spaced bins. Parameters ---------- x, y : `~numpy.ndarray` The position of the points to bin in the 2D histogram bins : int or iterable The number of bins in each dimension. If given as an integer, the same number of bins is used for each dimension. range : iterable The range to use in each dimention, as an iterable of value pairs, i.e. [(xmin, xmax), (ymin, ymax)] weights : `~numpy.ndarray` The weights of the points in the 1D histogram Returns ------- array : `~numpy.ndarray` The 2D histogram array """ if isinstance(bins, numbers.Integral): nx = ny = bins else: nx, ny = bins if not np.isscalar(nx) or not np.isscalar(ny): raise TypeError('bins should be an iterable of two integers') (xmin, xmax), (ymin, ymax) = range if not np.isfinite(xmin): raise ValueError("xmin should be finite") if not np.isfinite(xmax): raise ValueError("xmax should be finite") if not np.isfinite(ymin): raise ValueError("ymin should be finite") if not np.isfinite(ymax): raise ValueError("ymax should be finite") if xmax <= xmin: raise ValueError("xmax should be greater than xmin") if ymax <= ymin: raise ValueError("xmax should be greater than xmin") if nx <= 0: raise ValueError("nx should be strictly positive") if ny <= 0: raise ValueError("ny should be strictly positive") if weights is None: return _histogram2d(x, y, nx, xmin, xmax, ny, ymin, ymax) else: return _histogram2d_weighted(x, y, weights, nx, xmin, xmax, ny, ymin, ymax) fast-histogram-0.9/fast_histogram/tests/0000755000175100001660000000000013662557242020773 5ustar vstsdocker00000000000000fast-histogram-0.9/fast_histogram/tests/__init__.py0000644000175100001660000000000013662557224023072 0ustar vstsdocker00000000000000fast-histogram-0.9/fast_histogram/tests/test_histogram.py0000644000175100001660000001705013662557224024404 0ustar vstsdocker00000000000000import numpy as np import pytest from hypothesis import given, settings, assume from hypothesis import strategies as st from hypothesis.extra.numpy import arrays from ..histogram import histogram1d, histogram2d # NOTE: for now we don't test the full range of floating-point values in the # tests below, because Numpy's behavior isn't always deterministic in some # of the extreme regimes. We should add manual (non-hypothesis and not # comparing to Numpy) test cases. @given(values=arrays(dtype='f4', 'f8', '= xmin) if weights: assume(np.allclose(np.sum(w[inside]), np.sum(reference))) else: n_inside = np.sum(inside) assume(n_inside == np.sum(reference)) fast = histogram1d(x, bins=nx, weights=w, range=(xmin, xmax)) # Numpy returns results for 32-bit results as a 32-bit histogram, but only # for 1D arrays. Since this is a summation variable it makes sense to # return 64-bit, so rather than changing the behavior of histogram1d, we # cast to 32-bit float here. if x.dtype.kind == 'f' and x.dtype.itemsize == 4: rtol = 1e-7 else: rtol = 1e-14 np.testing.assert_allclose(fast, reference, rtol=rtol) @given(values=arrays(dtype='f4', 'f8', '= xmin) & (y < ymax) & (y >= ymin) if weights: assume(np.allclose(np.sum(w[inside]), np.sum(reference))) else: n_inside = np.sum(inside) assume(n_inside == np.sum(reference)) fast = histogram2d(x, y, bins=(nx, ny), weights=w, range=((xmin, xmax), (ymin, ymax))) if x.dtype.kind == 'f' and x.dtype.itemsize == 4: rtol = 1e-7 else: rtol = 1e-14 np.testing.assert_allclose(fast, reference, rtol=rtol) def test_nd_arrays(): x = np.random.random(1000) result_1d = histogram1d(x, bins=10, range=(0, 1)) result_3d = histogram1d(x.reshape((10, 10, 10)), bins=10, range=(0, 1)) np.testing.assert_equal(result_1d, result_3d) y = np.random.random(1000) result_1d = histogram2d(x, y, bins=(10, 10), range=[(0, 1), (0, 1)]) result_3d = histogram2d(x.reshape((10, 10, 10)), y.reshape((10, 10, 10)), bins=(10, 10), range=[(0, 1), (0, 1)]) np.testing.assert_equal(result_1d, result_3d) def test_list(): # Make sure that lists can be passed in x_list = [1.4, 2.1, 4.2] x_arr = np.array(x_list) result_list = histogram1d(x_list, bins=10, range=(0, 10)) result_arr = histogram1d(x_arr, bins=10, range=(0, 10)) np.testing.assert_equal(result_list, result_arr) def test_non_contiguous(): x = np.random.random((10, 10, 10))[::2, ::3, :] y = np.random.random((10, 10, 10))[::2, ::3, :] w = np.random.random((10, 10, 10))[::2, ::3, :] assert not x.flags.c_contiguous assert not x.flags.f_contiguous result_1 = histogram1d(x, bins=10, range=(0, 1)) result_2 = histogram1d(x.copy(), bins=10, range=(0, 1)) np.testing.assert_equal(result_1, result_2) result_1 = histogram1d(x, bins=10, range=(0, 1), weights=w) result_2 = histogram1d(x.copy(), bins=10, range=(0, 1), weights=w) np.testing.assert_equal(result_1, result_2) result_1 = histogram2d(x, y, bins=(10, 10), range=[(0, 1), (0, 1)]) result_2 = histogram2d(x.copy(), y.copy(), bins=(10, 10), range=[(0, 1), (0, 1)]) np.testing.assert_equal(result_1, result_2) result_1 = histogram2d(x, y, bins=(10, 10), range=[(0, 1), (0, 1)], weights=w) result_2 = histogram2d(x.copy(), y.copy(), bins=(10, 10), range=[(0, 1), (0, 1)], weights=w) np.testing.assert_equal(result_1, result_2) def test_array_bins(): edges = np.array([0, 1, 2, 3, 4]) with pytest.raises(TypeError) as exc: histogram1d([1, 2, 3], bins=edges, range=(0, 10)) assert exc.value.args[0] == 'bins should be an integer' with pytest.raises(TypeError) as exc: histogram2d([1, 2, 3], [1, 2 ,3], bins=[edges, edges], range=[(0, 10), (0, 10)]) assert exc.value.args[0] == 'bins should be an iterable of two integers' def test_mixed_strides(): # Make sure all functions work properly when passed arrays with mismatched # strides. x = np.random.random((30, 20, 40, 50))[:, 10, :, 20] y = np.random.random((30, 40, 50))[:, :, 10] z = np.random.random((30, 10, 5, 80, 90))[:, 5, 2, ::2, 22] assert x.shape == y.shape and x.shape == z.shape assert x.strides != y.strides and y.strides != z.strides and z.strides != x.strides result_1 = histogram1d(x, bins=10, range=(0, 1)) result_2, _ = np.histogram(x, bins=10, range=(0, 1)) np.testing.assert_equal(result_1, result_2) result_3 = histogram1d(x, weights=y, bins=10, range=(0, 1)) result_4, _ = np.histogram(x, weights=y, bins=10, range=(0, 1)) np.testing.assert_equal(result_3, result_4) result_5 = histogram2d(x, y, bins=(10, 10), range=[(0, 1), (0, 1)]) result_6, _, _ = np.histogram2d(x.ravel(), y.ravel(), bins=(10, 10), range=[(0, 1), (0, 1)]) np.testing.assert_equal(result_5, result_6) result_7 = histogram2d(x, y, weights=z, bins=(10, 10), range=[(0, 1), (0, 1)]) result_8, _, _ = np.histogram2d(x.ravel(), y.ravel(), weights=z.ravel(), bins=(10, 10), range=[(0, 1), (0, 1)]) np.testing.assert_equal(result_7, result_8) fast-histogram-0.9/fast_histogram/version.py0000644000175100001660000000016213662557241021666 0ustar vstsdocker00000000000000# coding: utf-8 # file generated by setuptools_scm # don't change, don't track in version control version = '0.9' fast-histogram-0.9/fast_histogram.egg-info/0000755000175100001660000000000013662557242021323 5ustar vstsdocker00000000000000fast-histogram-0.9/fast_histogram.egg-info/PKG-INFO0000644000175100001660000001725413662557241022430 0ustar vstsdocker00000000000000Metadata-Version: 2.1 Name: fast-histogram Version: 0.9 Summary: Fast simple 1D and 2D histograms Home-page: https://github.com/astrofrog/fast-histogram Author: Thomas Robitaille Author-email: thomas.robitaille@gmail.com License: BSD Description: |Azure Status| |asv| About ----- Sometimes you just want to compute simple 1D or 2D histograms with regular bins. Fast. No nonsense. `Numpy's `__ histogram functions are versatile, and can handle for example non-regular binning, but this versatility comes at the expense of performance. The **fast-histogram** mini-package aims to provide simple and fast histogram functions for regular bins that don't compromise on performance. It doesn't do anything complicated - it just implements a simple histogram algorithm in C and keeps it simple. The aim is to have functions that are fast but also robust and reliable. The result is a 1D histogram function here that is **7-15x faster** than ``numpy.histogram``, and a 2D histogram function that is **20-25x faster** than ``numpy.histogram2d``. To install:: pip install fast-histogram or if you use conda you can instead do:: conda install -c conda-forge fast-histogram The ``fast_histogram`` module then provides two functions: ``histogram1d`` and ``histogram2d``: .. code:: python from fast_histogram import histogram1d, histogram2d Example ------- Here's an example of binning 10 million points into a regular 2D histogram: .. code:: python In [1]: import numpy as np In [2]: x = np.random.random(10_000_000) In [3]: y = np.random.random(10_000_000) In [4]: %timeit _ = np.histogram2d(x, y, range=[[-1, 2], [-2, 4]], bins=30) 935 ms ± 58.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each) In [5]: from fast_histogram import histogram2d In [6]: %timeit _ = histogram2d(x, y, range=[[-1, 2], [-2, 4]], bins=30) 40.2 ms ± 624 µs per loop (mean ± std. dev. of 7 runs, 10 loops each) (note that ``10_000_000`` is possible in Python 3.6 syntax, use ``10000000`` instead in previous versions) The version here is over 20 times faster! The following plot shows the speedup as a function of array size for the bin parameters shown above: .. figure:: https://github.com/astrofrog/fast-histogram/raw/master/speedup_compared.png :alt: Comparison of performance between Numpy and fast-histogram as well as results for the 1D case, also with 30 bins. The speedup for the 2D case is consistently between 20-25x, and for the 1D case goes from 15x for small arrays to around 7x for large arrays. Q&A --- Why don't the histogram functions return the edges? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Computing and returning the edges may seem trivial but it can slow things down by a factor of a few when computing histograms of 10^5 or fewer elements, so not returning the edges is a deliberate decision related to performance. You can easily compute the edges yourself if needed though, using ``numpy.linspace``. Doesn't package X already do this, but better? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This may very well be the case! If this duplicates another package, or if it is possible to use Numpy in a smarter way to get the same performance gains, please open an issue and I'll consider deprecating this package :) One package that does include fast histogram functions (including in n-dimensions) and can compute other statistics is `vaex `_, so take a look there if you need more advanced functionality! Are the 2D histograms not transposed compared to what they should be? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ There is technically no 'right' and 'wrong' orientation - here we adopt the convention which gives results consistent with Numpy, so: .. code:: python numpy.histogram2d(x, y, range=[[xmin, xmax], [ymin, ymax]], bins=[nx, ny]) should give the same result as: .. code:: python fast_histogram.histogram2d(x, y, range=[[xmin, xmax], [ymin, ymax]], bins=[nx, ny]) Why not contribute this to Numpy directly? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ As mentioned above, the Numpy functions are much more versatile, so they could not be replaced by the ones here. One option would be to check in Numpy's functions for cases that are simple and dispatch to functions such as the ones here, or add dedicated functions for regular binning. I hope we can get this in Numpy in some form or another eventually, but for now, the aim is to have this available to packages that need to support a range of Numpy versions. Why not use Cython? ~~~~~~~~~~~~~~~~~~~ I originally implemented this in Cython, but found that I could get a 50% performance improvement by going straight to a C extension. What about using Numba? ~~~~~~~~~~~~~~~~~~~~~~~ I specifically want to keep this package as easy as possible to install, and while `Numba `__ is a great package, it is not trivial to install outside of Anaconda. Could this be parallelized? ~~~~~~~~~~~~~~~~~~~~~~~~~~~ This may benefit from parallelization under certain circumstances. The easiest solution might be to use OpenMP, but this won't work on all platforms, so it would need to be made optional. Couldn't you make it faster by using the GPU? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Almost certainly, though the aim here is to have an easily installable and portable package, and introducing GPUs is going to affect both of these. Why make a package specifically for this? This is a tiny amount of functionality ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Packages that need this could simply bundle their own C extension or Cython code to do this, but the main motivation for releasing this as a mini-package is to avoid making pure-Python packages into packages that require compilation just because of the need to compute fast histograms. Can I contribute? ~~~~~~~~~~~~~~~~~ Yes please! This is not meant to be a finished package, and I welcome pull request to improve things. .. |Azure Status| image:: https://dev.azure.com/thomasrobitaille/fast-histogram/_apis/build/status/astrofrog.fast-histogram?branchName=master :target: https://dev.azure.com/thomasrobitaille/fast-histogram/_build/latest?definitionId=13&branchName=master .. |asv| image:: https://img.shields.io/badge/benchmarked%20by-asv-brightgreen.svg :target: https://astrofrog.github.io/fast-histogram Platform: UNKNOWN Requires-Python: >=3.6 Provides-Extra: test fast-histogram-0.9/fast_histogram.egg-info/SOURCES.txt0000644000175100001660000000114513662557242023210 0ustar vstsdocker00000000000000.gitignore CHANGES.rst LICENSE MANIFEST.in README.rst azure-pipelines.yml pyproject.toml setup.cfg setup.py speedup_compared.png tox.ini comparison/README.rst comparison/benchmark.py comparison/plot.py fast_histogram/__init__.py fast_histogram/_histogram_core.c fast_histogram/histogram.py fast_histogram/version.py fast_histogram.egg-info/PKG-INFO fast_histogram.egg-info/SOURCES.txt fast_histogram.egg-info/dependency_links.txt fast_histogram.egg-info/not-zip-safe fast_histogram.egg-info/requires.txt fast_histogram.egg-info/top_level.txt fast_histogram/tests/__init__.py fast_histogram/tests/test_histogram.pyfast-histogram-0.9/fast_histogram.egg-info/dependency_links.txt0000644000175100001660000000000113662557241025370 0ustar vstsdocker00000000000000 fast-histogram-0.9/fast_histogram.egg-info/not-zip-safe0000644000175100001660000000000113662557241023550 0ustar vstsdocker00000000000000 fast-histogram-0.9/fast_histogram.egg-info/requires.txt0000644000175100001660000000006213662557241023720 0ustar vstsdocker00000000000000numpy [test] pytest pytest-cov hypothesis[numpy] fast-histogram-0.9/fast_histogram.egg-info/top_level.txt0000644000175100001660000000001713662557241024052 0ustar vstsdocker00000000000000fast_histogram fast-histogram-0.9/pyproject.toml0000644000175100001660000000025213662557224017532 0ustar vstsdocker00000000000000[build-system] requires = ["setuptools", "setuptools_scm", "wheel", "oldest-supported-numpy"] build-backend = 'setuptools.build_meta' fast-histogram-0.9/setup.cfg0000644000175100001660000000075413662557242016446 0ustar vstsdocker00000000000000[metadata] name = fast-histogram url = https://github.com/astrofrog/fast-histogram author = Thomas Robitaille author_email = thomas.robitaille@gmail.com license = BSD description = Fast simple 1D and 2D histograms long_description = file: README.rst [options] zip_safe = False packages = find: setup_requires = setuptools_scm install_requires = numpy python_requires = >=3.6 [options.extras_require] test = pytest pytest-cov hypothesis[numpy] [egg_info] tag_build = tag_date = 0 fast-histogram-0.9/setup.py0000644000175100001660000000065413662557224016336 0ustar vstsdocker00000000000000#!/usr/bin/env python import os import sys import numpy from setuptools import setup from setuptools.extension import Extension setup(use_scm_version={'write_to': os.path.join('fast_histogram', 'version.py')}, ext_modules=[Extension("fast_histogram._histogram_core", [os.path.join('fast_histogram', '_histogram_core.c')], include_dirs=[numpy.get_include()])]) fast-histogram-0.9/speedup_compared.png0000644000175100001660000006276613662557224020665 0ustar vstsdocker00000000000000PNG  IHDR6, sBIT|d pHYsaa?i9tEXtSoftwarematplotlib version 2.2.2, http://matplotlib.org/ IDATxwxTed2Ҩ!R*4MĆeuŲkwWQ 5 EP@ BH uǁ@ j&Lr2syS,Á0WQ`#"""nCFDDD܆ q 6"""6lDDDm(؈Paj8q"͚5#(( ڷoҥKwŒqXf3ZhVh>3}]~g7nLΝWjlV"""Ry}_gĉlڴƍGʕ(ODDDS͕rrr7oo>̙3T={d̘1u233{ٳg bkDDD5ϟjժxx81ra;v8VXxq޹ɓ';bbb;wt̞=QfMG׮]zcƌqz衇z衇<رc;w)SvZ5jT[nulݺ-[^zINNFiO+vV^M7݄f+,)j[٤M6pmԪUs95[Q^^^y[nO?ϤI e˖l68ooCBB rmnGhh[Vlr綁{Omv0Rrݻwc۩RJ W%"""e=6/={$22_f-[ơCիaaaٳQFѢE :vhf"""RJlN:ŰaÈ'88f͚l2uF\\V… DFFһwoƌj5l)L 6SNs]ԍ)*q 6"""6lDDDm(؈P`#"""nCFDDD܆ q 6"""6lDDDm(؈P`#"""nCFDDD܆ q 6"""6<.@J,HK33ig^8M$ ^~`Ň_{<|s(cȵSqgdb01BůW>OKsyI 㮭ӧ`@2]5 zښEDQ)k3r%G,ڝ ~f<.} p+֟iӢ)Y`O{ůW+K=,e `²ڌA\5(C&s>CDYDDLBK@85fUQ;X,5J`#R\<Р7ܿ n팽~&_][Q)n ð!͞aJW{bv""nAF$E WOa+`]DDDF O.f|5R1ShW3|V3qHipՌ\\͸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l,ܼyF~~~ ⭙}`2<7xgp# [nE޽],oذaǝ;ڽ^kX[NN&NA &O01ʵȒΜ9_r2 S9s' a(*N޽{–-[]bY[~=z@.cРA1bkePmlĈ<Ѷޜ^'d,xPo,xe &ة"yPolj'(& :CwY6޼<6k=?˪le˖P(Rϯp{{sN97`c#...u~RR/RU!iޜ{sN1Pi^BFFѮ];㥗^B^cҥr x {{co7Q}XNlϞ=Z_/yZ \\\={ l)&7G؛YQDDD$<dž$$$$$$$$$YVB.lP(2dإXmܸq8e 񳢈Q&M,_OFvVF(j*K%GglqFİaðjժj L;wW^PHMMEbb""""E/IDATrJtj ?x 4o>>>6l~7~iL C&tU7-ZFK.5HD`CD at;wƋ/ouM'$$`ܹ8s ظq#lق A)>>iiiؽ{7r9Fbvhݺu}]^xHKKCzz:MVPZZ_ׯ#''À%%%RRRo>xxx`Ȑ!(++klK "j -A вeK!))ɼ~Ϟ=a۶m7sLAR ~~@8q oooaÆ m"""z)Zu~U)SAAAWX!tY0Lmz&ܹ}pƆܹs8t{9RĸqrZիXPPZjUm~C\\:tF`+Wj/1222p1L0:1i$DGGc޼ymgҥXb~s̄'<<<ooot:ID|&DDXh۶yLT*Ef͚պ]cÇG`` -[L&t޽ڡI&!""999Xr% zLLLD\\cǎ9s&֯_QFչ޽{? =& Xvm hD$"Zyy9֬Y> 111֍3k׮uܺu gΜ7|c>e߾} E^l2[_~Cxl2331fѣٳ'6l___h4z#"("O?L8ݻw5vXX}Vhҥ?:4i͛X bػw/._#-- ]tsÇ#""rss_@I-[ȑ#,$''FNNQ`!"Xn̘1#Gڧ\.둞ݻwŧ~Z? nݺ#$$1tP̚5ֶyyy8{,~gM6/pwwGJJ ڵkѣGK.xWPZZ" F푖={]9"rׯ_Ǵi̇("rGPPӱd!"""" d0d0d0d0d0d0d0d?ƯɊIENDB`fast-histogram-0.9/tox.ini0000644000175100001660000000157513662557224016142 0ustar vstsdocker00000000000000[tox] envlist = py{27, 35, 36,37,38}-test style requires = setuptools >= 30.3.0 pip >= 19.3.1 isolated_build = true [testenv] changedir = test: .tmp/{envname} build_docs: docs description = test: run tests with pytest build_docs: invoke sphinx-build to build the HTML docs all: run tests with all optional dependencies dev: run tests with numpy and astropy dev versions deps = numpy110: numpy==1.10.* numpy111: numpy==1.11.* numpy112: numpy==1.12.* numpy113: numpy==1.13.* numpy114: numpy==1.14.* numpy115: numpy==1.15.* numpy116: numpy==1.16.* numpy117: numpy==1.17.* numpy118: numpy==1.18.* extras = test commands = pip freeze pytest --pyargs fast_histogram {posargs} [testenv:style] skip_install = true description = invoke style checks on package code deps = flake8 commands = flake8 fast_histogram