sortednp


Namesortednp JSON
Version 0.5.0 PyPI version JSON
download
home_pagehttps://sortednp.dev/
SummaryMerge and intersect sorted numpy arrays.
upload_time2024-03-13 06:46:54
maintainer
docs_urlNone
authorFrank Sauerburger
requires_python>=3
licenseMIT
keywords merge intersect sorted numpy
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Sortednp

The package to intersect or merge sorted numpy arrays.

[![Pipeline](https://gitlab.sauerburger.com/frank/sortednp/badges/main/pipeline.svg)](https://gitlab.sauerburger.com/frank/sortednp/-/pipelines)
[![Pylint](https://gitlab.sauerburger.com/frank/sortednp/-/jobs/artifacts/main/raw/pylint.svg?job=pylint)](https://gitlab.sauerburger.com/frank/sortednp)
[![C++ lint](https://gitlab.sauerburger.com/frank/sortednp/-/jobs/artifacts/main/raw/cxxlint.svg?job=cpplint)](https://gitlab.sauerburger.com/frank/sortednp)
[![License](https://gitlab.sauerburger.com/frank/sortednp/-/jobs/artifacts/main/raw/license.svg?job=badges)](https://gitlab.sauerburger.com/frank/sortednp/-/blob/main/LICENSE)
[![PyPI](https://gitlab.sauerburger.com/frank/sortednp/-/jobs/artifacts/main/raw/pypi.svg?job=badges)](https://pypi.org/project/sortednp/)

Numpy and Numpy arrays are a really great tool. However, intersecting and
merging multiple sorted numpy arrays is rather less performant. The current numpy
implementation concatenates the two arrays and sorts the combination. If you
want to merge or intersect multiple numpy arrays, there is a much faster way,
by using the property, that the resulting array is sorted.

Sortednp (sorted numpy) operates on sorted numpy arrays to calculate the
intersection or the union of two numpy arrays in an efficient way. The
resulting array is again a sorted numpy array, which can be merged or
intersected with the next array. The intended use case is that sorted numpy
arrays are sorted as the basic data structure and merged or intersected at
request. Typical applications include information retrieval and search engines
in particular.

It is also possible to implement a k-way merging or intersecting algorithm,
which operates on an arbitrary number of arrays at the same time. This package
is intended to deal with arrays with $`10^6`$ or $`10^{10}`$ items. Usually, these
arrays are too large to keep more than two of them in memory at the same
time. This package implements methods to merge and intersect multiple arrays,
which can be loaded on-demand.

## Links
- [Git Repository](https://gitlab.sauerburger.com/frank/sortednp)
- [Documentation](https://sortednp.dev)
- [PyPI](https://pypi.org/project/sortednp/)

## Installation from PyPI

You can install the package directly from PyPI using `pip`.

```bash
$ pip install sortednp
```

### Numpy Dependency
The installation fails in some cases, because of a build-time dependency on
numpy. Usually, the problem can be solved by manually installing a recent numpy
version via `pip install -U numpy`.

ju
## Basic Usage
### Two-way intersection

Two sorted numpy arrays can be intersected with the `intersect` method, which takes two
numpy arrays and returns the sorted intersection of the two arrays.

<!-- write intersect.py -->
```python
## intersect.py
import numpy as np
import sortednp as snp

a = np.array([0, 3, 4, 6, 7])
b = np.array([1, 2, 3, 5, 7, 9])

i = snp.intersect(a, b)
print(i)
```

If you run this, you should see the intersection of both arrays as a sorted numpy
array.
<!-- console_output -->
```python
$ python3 intersect.py
[3 7]
```

### Two-way union

Two numpy sorted arrays can be merged with the `merge` method, which takes two
numpy arrays and returns the sorted union of the two arrays.

<!-- write merge.py -->
```python
## merge.py
import numpy as np
import sortednp as snp

a = np.array([0, 3, 4, 6, 7])
b = np.array([1, 2, 3, 5, 7, 9])

m = snp.merge(a, b)
print(m)
```

If you run this, you should see the union of both arrays as a sorted numpy
array.
<!-- console_output -->
```python
$ python3 merge.py
[0 1 2 3 3 4 5 6 7 7 9]
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://sortednp.dev/",
    "name": "sortednp",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": "",
    "keywords": "merge intersect sorted numpy",
    "author": "Frank Sauerburger",
    "author_email": "frank@sauerburger.com",
    "download_url": "https://files.pythonhosted.org/packages/06/c2/eb064e203fd25409580c25ae140e01a00e423b1f0c965770d639ad88fc83/sortednp-0.5.0.tar.gz",
    "platform": "Linux",
    "description": "# Sortednp\n\nThe package to intersect or merge sorted numpy arrays.\n\n[![Pipeline](https://gitlab.sauerburger.com/frank/sortednp/badges/main/pipeline.svg)](https://gitlab.sauerburger.com/frank/sortednp/-/pipelines)\n[![Pylint](https://gitlab.sauerburger.com/frank/sortednp/-/jobs/artifacts/main/raw/pylint.svg?job=pylint)](https://gitlab.sauerburger.com/frank/sortednp)\n[![C++ lint](https://gitlab.sauerburger.com/frank/sortednp/-/jobs/artifacts/main/raw/cxxlint.svg?job=cpplint)](https://gitlab.sauerburger.com/frank/sortednp)\n[![License](https://gitlab.sauerburger.com/frank/sortednp/-/jobs/artifacts/main/raw/license.svg?job=badges)](https://gitlab.sauerburger.com/frank/sortednp/-/blob/main/LICENSE)\n[![PyPI](https://gitlab.sauerburger.com/frank/sortednp/-/jobs/artifacts/main/raw/pypi.svg?job=badges)](https://pypi.org/project/sortednp/)\n\nNumpy and Numpy arrays are a really great tool. However, intersecting and\nmerging multiple sorted numpy arrays is rather less performant. The current numpy\nimplementation concatenates the two arrays and sorts the combination. If you\nwant to merge or intersect multiple numpy arrays, there is a much faster way,\nby using the property, that the resulting array is sorted.\n\nSortednp (sorted numpy) operates on sorted numpy arrays to calculate the\nintersection or the union of two numpy arrays in an efficient way. The\nresulting array is again a sorted numpy array, which can be merged or\nintersected with the next array. The intended use case is that sorted numpy\narrays are sorted as the basic data structure and merged or intersected at\nrequest. Typical applications include information retrieval and search engines\nin particular.\n\nIt is also possible to implement a k-way merging or intersecting algorithm,\nwhich operates on an arbitrary number of arrays at the same time. This package\nis intended to deal with arrays with $`10^6`$ or $`10^{10}`$ items. Usually, these\narrays are too large to keep more than two of them in memory at the same\ntime. This package implements methods to merge and intersect multiple arrays,\nwhich can be loaded on-demand.\n\n## Links\n- [Git Repository](https://gitlab.sauerburger.com/frank/sortednp)\n- [Documentation](https://sortednp.dev)\n- [PyPI](https://pypi.org/project/sortednp/)\n\n## Installation from PyPI\n\nYou can install the package directly from PyPI using `pip`.\n\n```bash\n$ pip install sortednp\n```\n\n### Numpy Dependency\nThe installation fails in some cases, because of a build-time dependency on\nnumpy. Usually, the problem can be solved by manually installing a recent numpy\nversion via `pip install -U numpy`.\n\nju\n## Basic Usage\n### Two-way intersection\n\nTwo sorted numpy arrays can be intersected with the `intersect` method, which takes two\nnumpy arrays and returns the sorted intersection of the two arrays.\n\n<!-- write intersect.py -->\n```python\n## intersect.py\nimport numpy as np\nimport sortednp as snp\n\na = np.array([0, 3, 4, 6, 7])\nb = np.array([1, 2, 3, 5, 7, 9])\n\ni = snp.intersect(a, b)\nprint(i)\n```\n\nIf you run this, you should see the intersection of both arrays as a sorted numpy\narray.\n<!-- console_output -->\n```python\n$ python3 intersect.py\n[3 7]\n```\n\n### Two-way union\n\nTwo numpy sorted arrays can be merged with the `merge` method, which takes two\nnumpy arrays and returns the sorted union of the two arrays.\n\n<!-- write merge.py -->\n```python\n## merge.py\nimport numpy as np\nimport sortednp as snp\n\na = np.array([0, 3, 4, 6, 7])\nb = np.array([1, 2, 3, 5, 7, 9])\n\nm = snp.merge(a, b)\nprint(m)\n```\n\nIf you run this, you should see the union of both arrays as a sorted numpy\narray.\n<!-- console_output -->\n```python\n$ python3 merge.py\n[0 1 2 3 3 4 5 6 7 7 9]\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Merge and intersect sorted numpy arrays.",
    "version": "0.5.0",
    "project_urls": {
        "Homepage": "https://sortednp.dev/"
    },
    "split_keywords": [
        "merge",
        "intersect",
        "sorted",
        "numpy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bb0487cd8c3edfdfcd6423fd5c53511d4acebb39417650bdc37e607e070d7822",
                "md5": "78dce799f361b57609bc3ba012340cf7",
                "sha256": "63f4f471cab3329d47a29f157965d154a4bb6fa190a3c878723df4075e50bc56"
            },
            "downloads": -1,
            "filename": "sortednp-0.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
            "has_sig": false,
            "md5_digest": "78dce799f361b57609bc3ba012340cf7",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3",
            "size": 173310,
            "upload_time": "2024-03-13T06:46:43",
            "upload_time_iso_8601": "2024-03-13T06:46:43.121727Z",
            "url": "https://files.pythonhosted.org/packages/bb/04/87cd8c3edfdfcd6423fd5c53511d4acebb39417650bdc37e607e070d7822/sortednp-0.5.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7dfd7b8ad2228b1ce9eb4c545b9292ca52fa4ba654095493d28c5707ff449504",
                "md5": "fa18e3da9e77a42ec54ba6451d66dcae",
                "sha256": "cc3942cb780c8861478bc29e5f32ec4757649e338ee210a61e56a1ce6e9b8243"
            },
            "downloads": -1,
            "filename": "sortednp-0.5.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
            "has_sig": false,
            "md5_digest": "fa18e3da9e77a42ec54ba6451d66dcae",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3",
            "size": 173334,
            "upload_time": "2024-03-13T06:46:45",
            "upload_time_iso_8601": "2024-03-13T06:46:45.765271Z",
            "url": "https://files.pythonhosted.org/packages/7d/fd/7b8ad2228b1ce9eb4c545b9292ca52fa4ba654095493d28c5707ff449504/sortednp-0.5.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "886a275cd6283a5b571b5b8f090633913351f579663385d05f8e010e706c4445",
                "md5": "fbb3c5c992d95d6da815c6fc62a30f05",
                "sha256": "3b08bdcb66a21f5d21d7c8bac641eff907d0ff696c006a628b835b9524ec9377"
            },
            "downloads": -1,
            "filename": "sortednp-0.5.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
            "has_sig": false,
            "md5_digest": "fbb3c5c992d95d6da815c6fc62a30f05",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3",
            "size": 177239,
            "upload_time": "2024-03-13T06:46:48",
            "upload_time_iso_8601": "2024-03-13T06:46:48.221715Z",
            "url": "https://files.pythonhosted.org/packages/88/6a/275cd6283a5b571b5b8f090633913351f579663385d05f8e010e706c4445/sortednp-0.5.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fd69bdf85b5e8941104eeb47f1b3d1b427ea82d0c4278f69ca8f1134ce3d8d7b",
                "md5": "6301efd0baf66dfaa3f1d9cab360dd31",
                "sha256": "9f1913d76a891d78fff1b24ead21b322d27ef32a4e6490588109ae4d3b721f18"
            },
            "downloads": -1,
            "filename": "sortednp-0.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
            "has_sig": false,
            "md5_digest": "6301efd0baf66dfaa3f1d9cab360dd31",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3",
            "size": 176957,
            "upload_time": "2024-03-13T06:46:50",
            "upload_time_iso_8601": "2024-03-13T06:46:50.357822Z",
            "url": "https://files.pythonhosted.org/packages/fd/69/bdf85b5e8941104eeb47f1b3d1b427ea82d0c4278f69ca8f1134ce3d8d7b/sortednp-0.5.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "377f3dde5f7a8fa4b670c95054b30c05874ef0f5d0ac00afa608a0379096d0ce",
                "md5": "54be2bb3d666f09529f514e98baa7538",
                "sha256": "2c7061363c5d2dd3a8739d5dd2d812668ba13acc31665e68a35a08676db44fc6"
            },
            "downloads": -1,
            "filename": "sortednp-0.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
            "has_sig": false,
            "md5_digest": "54be2bb3d666f09529f514e98baa7538",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": ">=3",
            "size": 173102,
            "upload_time": "2024-03-13T06:46:52",
            "upload_time_iso_8601": "2024-03-13T06:46:52.444646Z",
            "url": "https://files.pythonhosted.org/packages/37/7f/3dde5f7a8fa4b670c95054b30c05874ef0f5d0ac00afa608a0379096d0ce/sortednp-0.5.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "06c2eb064e203fd25409580c25ae140e01a00e423b1f0c965770d639ad88fc83",
                "md5": "25385c090773c537857f2cc59226c81a",
                "sha256": "6dbd9964ac49eb1822846f880823b44c5311f7c10b2087532db33dc3e32e74d1"
            },
            "downloads": -1,
            "filename": "sortednp-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "25385c090773c537857f2cc59226c81a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3",
            "size": 31145,
            "upload_time": "2024-03-13T06:46:54",
            "upload_time_iso_8601": "2024-03-13T06:46:54.448119Z",
            "url": "https://files.pythonhosted.org/packages/06/c2/eb064e203fd25409580c25ae140e01a00e423b1f0c965770d639ad88fc83/sortednp-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-13 06:46:54",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "sortednp"
}
        
Elapsed time: 0.20912s