npstreams


Namenpstreams JSON
Version 1.7.0 PyPI version JSON
download
home_pageNone
SummaryStreaming operations on NumPy arrays
upload_time2024-10-23 18:35:36
maintainerLaurent P. René de Cotret
docs_urlNone
authorLaurent P. René de Cotret
requires_python>=3.7
licenseBSD
keywords streaming numpy math
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # npstreams

[![Documentation Build Status](https://readthedocs.org/projects/npstreams/badge/?version=master)](http://npstreams.readthedocs.io) [![PyPI Version](https://img.shields.io/pypi/v/npstreams.svg)](https://pypi.python.org/pypi/npstreams) [![Conda-forge Version](https://img.shields.io/conda/vn/conda-forge/npstreams.svg)](https://anaconda.org/conda-forge/npstreams) [![DOI badge](https://img.shields.io/badge/DOI-10.1186%2Fs40679--018--0060--y-blue)](https://doi.org/10.1186/s40679-018-0060-y)

npstreams is an open-source Python package for streaming NumPy array
operations. The goal is to provide tested routines that operate on
streams (or generators) of arrays instead of dense arrays.

Streaming reduction operations (sums, averages, etc.) can be implemented
in constant memory, which in turns allows for easy parallelization.

This approach has been a huge boon when working with lots of images; the
images are read one-by-one from disk and combined/processed in a
streaming fashion.

This package is developed in conjunction with other software projects in
the [Siwick research group](http://www.physics.mcgill.ca/siwicklab/).

## Motivating Example

Consider the following snippet to combine 50 images from an iterable
`source`:

```python
import numpy as np

images = np.empty( shape = (2048, 2048, 50) )
for index, im in enumerate(source):
    images[:,:,index] = im

avg = np.average(images, axis = 2)
```

If the `source` iterable provided 1000 images, the above routine would
not work on most machines. Moreover, what if we want to transform the
images one by one before averaging them? What about looking at the
average while it is being computed? Let\'s look at an example:

```python
import numpy as np
from npstreams import iaverage
from scipy.misc import imread

stream = map(imread, list_of_filenames)
averaged = iaverage(stream)
```

At this point, the generators `map` and `iaverage` are \'wired\' but
will not compute anything until it is requested. We can look at the
average evolve:

```python
import matplotlib.pyplot as plt
for avg in average:
    plt.imshow(avg); plt.show()
```

We can also use `last` to get at the final average:

```python
from npstreams import last

total = last(averaged) # average of the entire stream
```

## Streaming Functions

npstreams comes with some streaming functions built-in. Some examples:

-   Numerics : `isum`, `iprod`, `isub`, etc.
-   Statistics : `iaverage` (weighted mean), `ivar` (single-pass
    variance), etc.

More importantly, npstreams gives you all the tools required to build
your own streaming function. All routines are documented in the [API
Reference on readthedocs.io](http://npstreams.readthedocs.io).

## Benchmarking

npstreams provides a function for benchmarking common use cases.

To run the benchmark with default parameters, from the interpreter:

```python
from npstreams import benchmark
benchmark()
```

From a command-line terminal:

```bash
python -c 'import npstreams; npstreams.benchmark()'
```

The results will be printed to the screen.

## Future Work

Some of the features I want to implement in this package in the near
future:

-   Optimize the CUDA-enabled routines
-   More functions : more streaming functions borrowed from NumPy and
    SciPy.

## API Reference

The [API Reference on readthedocs.io](http://npstreams.readthedocs.io)
provides API-level documentation, as well as tutorials.

## Installation

The only requirement is NumPy. To have access to CUDA-enabled routines,
PyCUDA must also be installed. npstreams is available on PyPI; it can be
installed with [pip](https://pip.pypa.io).:

```bash
python -m pip install npstreams
```

npstreams can also be installed with the conda package manager, from the
conda-forge channel:

```bash
conda config --add channels conda-forge
conda install npstreams
```

To install the latest development version from
[Github](https://github.com/LaurentRDC/npstreams):

```bash
python -m pip install git+git://github.com/LaurentRDC/npstreams.git
```

Tests can be run using the `pytest` package.

## Citations

If you find this software useful, please consider citing the following
publication:

> L. P. René de Cotret, M. R. Otto, M. J. Stern. and B. J. Siwick, *An open-source software ecosystem for the interactive exploration of ultrafast electron scattering data*, Advanced Structural and Chemical Imaging 4:11 (2018) [DOI: 10.1186/s40679-018-0060-y.](https://ascimaging.springeropen.com/articles/10.1186/s40679-018-0060-y)


## Support / Report Issues

All support requests and issue reports should be [filed on Github as an
issue](https://github.com/LaurentRDC/npstreams/issues).

## License

npstreams is made available under the BSD License, same as NumPy. For
more details, see
[LICENSE.txt](https://github.com/LaurentRDC/npstreams/blob/master/LICENSE.txt).



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "npstreams",
    "maintainer": "Laurent P. Ren\u00e9 de Cotret",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "laurent.renedecotret@mail.mcgill.ca",
    "keywords": "streaming, numpy, math",
    "author": "Laurent P. Ren\u00e9 de Cotret",
    "author_email": "laurent.renedecotret@mail.mcgill.ca",
    "download_url": "https://files.pythonhosted.org/packages/c9/9a/ccac334d97fc155afd8f0184612fd032719db17027b159783c8cfb868719/npstreams-1.7.0.tar.gz",
    "platform": null,
    "description": "# npstreams\n\n[![Documentation Build Status](https://readthedocs.org/projects/npstreams/badge/?version=master)](http://npstreams.readthedocs.io) [![PyPI Version](https://img.shields.io/pypi/v/npstreams.svg)](https://pypi.python.org/pypi/npstreams) [![Conda-forge Version](https://img.shields.io/conda/vn/conda-forge/npstreams.svg)](https://anaconda.org/conda-forge/npstreams) [![DOI badge](https://img.shields.io/badge/DOI-10.1186%2Fs40679--018--0060--y-blue)](https://doi.org/10.1186/s40679-018-0060-y)\n\nnpstreams is an open-source Python package for streaming NumPy array\noperations. The goal is to provide tested routines that operate on\nstreams (or generators) of arrays instead of dense arrays.\n\nStreaming reduction operations (sums, averages, etc.) can be implemented\nin constant memory, which in turns allows for easy parallelization.\n\nThis approach has been a huge boon when working with lots of images; the\nimages are read one-by-one from disk and combined/processed in a\nstreaming fashion.\n\nThis package is developed in conjunction with other software projects in\nthe [Siwick research group](http://www.physics.mcgill.ca/siwicklab/).\n\n## Motivating Example\n\nConsider the following snippet to combine 50 images from an iterable\n`source`:\n\n```python\nimport numpy as np\n\nimages = np.empty( shape = (2048, 2048, 50) )\nfor index, im in enumerate(source):\n    images[:,:,index] = im\n\navg = np.average(images, axis = 2)\n```\n\nIf the `source` iterable provided 1000 images, the above routine would\nnot work on most machines. Moreover, what if we want to transform the\nimages one by one before averaging them? What about looking at the\naverage while it is being computed? Let\\'s look at an example:\n\n```python\nimport numpy as np\nfrom npstreams import iaverage\nfrom scipy.misc import imread\n\nstream = map(imread, list_of_filenames)\naveraged = iaverage(stream)\n```\n\nAt this point, the generators `map` and `iaverage` are \\'wired\\' but\nwill not compute anything until it is requested. We can look at the\naverage evolve:\n\n```python\nimport matplotlib.pyplot as plt\nfor avg in average:\n    plt.imshow(avg); plt.show()\n```\n\nWe can also use `last` to get at the final average:\n\n```python\nfrom npstreams import last\n\ntotal = last(averaged) # average of the entire stream\n```\n\n## Streaming Functions\n\nnpstreams comes with some streaming functions built-in. Some examples:\n\n-   Numerics : `isum`, `iprod`, `isub`, etc.\n-   Statistics : `iaverage` (weighted mean), `ivar` (single-pass\n    variance), etc.\n\nMore importantly, npstreams gives you all the tools required to build\nyour own streaming function. All routines are documented in the [API\nReference on readthedocs.io](http://npstreams.readthedocs.io).\n\n## Benchmarking\n\nnpstreams provides a function for benchmarking common use cases.\n\nTo run the benchmark with default parameters, from the interpreter:\n\n```python\nfrom npstreams import benchmark\nbenchmark()\n```\n\nFrom a command-line terminal:\n\n```bash\npython -c 'import npstreams; npstreams.benchmark()'\n```\n\nThe results will be printed to the screen.\n\n## Future Work\n\nSome of the features I want to implement in this package in the near\nfuture:\n\n-   Optimize the CUDA-enabled routines\n-   More functions : more streaming functions borrowed from NumPy and\n    SciPy.\n\n## API Reference\n\nThe [API Reference on readthedocs.io](http://npstreams.readthedocs.io)\nprovides API-level documentation, as well as tutorials.\n\n## Installation\n\nThe only requirement is NumPy. To have access to CUDA-enabled routines,\nPyCUDA must also be installed. npstreams is available on PyPI; it can be\ninstalled with [pip](https://pip.pypa.io).:\n\n```bash\npython -m pip install npstreams\n```\n\nnpstreams can also be installed with the conda package manager, from the\nconda-forge channel:\n\n```bash\nconda config --add channels conda-forge\nconda install npstreams\n```\n\nTo install the latest development version from\n[Github](https://github.com/LaurentRDC/npstreams):\n\n```bash\npython -m pip install git+git://github.com/LaurentRDC/npstreams.git\n```\n\nTests can be run using the `pytest` package.\n\n## Citations\n\nIf you find this software useful, please consider citing the following\npublication:\n\n> L. P. Ren\u00e9 de Cotret, M. R. Otto, M. J. Stern. and B. J. Siwick, *An open-source software ecosystem for the interactive exploration of ultrafast electron scattering data*, Advanced Structural and Chemical Imaging 4:11 (2018) [DOI: 10.1186/s40679-018-0060-y.](https://ascimaging.springeropen.com/articles/10.1186/s40679-018-0060-y)\n\n\n## Support / Report Issues\n\nAll support requests and issue reports should be [filed on Github as an\nissue](https://github.com/LaurentRDC/npstreams/issues).\n\n## License\n\nnpstreams is made available under the BSD License, same as NumPy. For\nmore details, see\n[LICENSE.txt](https://github.com/LaurentRDC/npstreams/blob/master/LICENSE.txt).\n\n\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Streaming operations on NumPy arrays",
    "version": "1.7.0",
    "project_urls": {
        "Download": "http://github.com/LaurentRDC/npstreams"
    },
    "split_keywords": [
        "streaming",
        " numpy",
        " math"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5c5671d7c2e2a8c0654a2ea6836a004f01daac66250a571920f13b0d279b14ec",
                "md5": "e12a78dc474dafcef8df1f5c9e9b6a86",
                "sha256": "bb6d1a1de26274b23c4979eb81925697a80d48199d2a4a54878473158ca1ccb6"
            },
            "downloads": -1,
            "filename": "npstreams-1.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e12a78dc474dafcef8df1f5c9e9b6a86",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 40135,
            "upload_time": "2024-10-23T18:12:47",
            "upload_time_iso_8601": "2024-10-23T18:12:47.043029Z",
            "url": "https://files.pythonhosted.org/packages/5c/56/71d7c2e2a8c0654a2ea6836a004f01daac66250a571920f13b0d279b14ec/npstreams-1.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c99accac334d97fc155afd8f0184612fd032719db17027b159783c8cfb868719",
                "md5": "e117b3ba578a938bd006fd58ae4c5831",
                "sha256": "af584a5a8b1882161de2a3b25b4bbfbbee85e69da75678f1b470df0c91c157ee"
            },
            "downloads": -1,
            "filename": "npstreams-1.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e117b3ba578a938bd006fd58ae4c5831",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 34276,
            "upload_time": "2024-10-23T18:35:36",
            "upload_time_iso_8601": "2024-10-23T18:35:36.699372Z",
            "url": "https://files.pythonhosted.org/packages/c9/9a/ccac334d97fc155afd8f0184612fd032719db17027b159783c8cfb868719/npstreams-1.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-23 18:35:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "LaurentRDC",
    "github_project": "npstreams",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "npstreams"
}
        
Elapsed time: 0.40703s