quads


Namequads JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/toastdriven/quads
SummaryA pure Python Quadtree implementation.
upload_time2020-07-22 21:15:06
maintainer
docs_urlNone
authorDaniel Lindsley
requires_python>=3.7,<4.0
licenseBSD-3-Clause
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # `quads`

[![Documentation Status](https://readthedocs.org/projects/quads/badge/?version=latest)](https://quads.readthedocs.io/en/latest/?badge=latest)
![CI](https://github.com/toastdriven/quads/workflows/CI/badge.svg)

A pure Python Quadtree implementation.

[Quadtrees](https://en.wikipedia.org/wiki/Quadtree) are a useful data
structure for sparse datasets where the location/position of the data is
important. They're especially good for spatial indexing & image processing.

An actual visualization of a `quads.QuadTree`:

![quadtree_viz](docs/images/quadtree_visualization.png)


## Usage

Full documentation at https://quads.readthedocs.io/en/latest/

```python
>>> import quads
>>> tree = quads.QuadTree(
...     (0, 0),  # The center point
...     10,  # The width
...     10,  # The height
... )

# You can choose to simply represent points that exist.
>>> tree.insert((1, 2))
True
# ...or include extra data at those points.
>>> tree.insert(quads.Point(4, -3, data="Samus"))
True

# You can search for a given point. It returns the point if found...
>>> tree.find((1, 2))
Point(1, 2)

# Or `None` if there's no match.
>>> tree.find((4, -4))
None

# You can also find all the points within a given region.
>>> bb = quads.BoundingBox(min_x=-1, min_y=-2, max_x=2, max_y=2)
>>> tree.within_bb(bb)
[Point(1, 2)]

# You can also search to find the nearest neighbors of a point, even
# if that point doesn't have data within the quadtree.
>>> tree.nearest_neighbors((0, 1), count=2)
[
    Point(1, 2),
    Point(4, -4),
]

# And if you have `matplotlib` installed (not required!), you can visualize
# the tree.
>>> quads.visualize(tree)
```


## Installation

```
$ pip install quads
```


## Requirements

* Python 3.7+ (untested on older versions but may work)


## Running Tests

```
$ git clone https://github.com/toastdriven/quads.git
$ cd quads
$ poetry install
$ poetry shell

# Just the tests.
$ pytest .

# With coverage.
$ pytest -s --cov=quads .
# And with pretty reports.
$ pytest -s --cov=quads . && coverage html
```


## License

New BSD

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/toastdriven/quads",
    "name": "quads",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Daniel Lindsley",
    "author_email": "daniel@toastdriven.com",
    "download_url": "https://files.pythonhosted.org/packages/74/c7/257b7c30a7483e7cc699d0faf1695a04d3251f955789339a8d8f50c74008/quads-1.1.0.tar.gz",
    "platform": "",
    "description": "# `quads`\n\n[![Documentation Status](https://readthedocs.org/projects/quads/badge/?version=latest)](https://quads.readthedocs.io/en/latest/?badge=latest)\n![CI](https://github.com/toastdriven/quads/workflows/CI/badge.svg)\n\nA pure Python Quadtree implementation.\n\n[Quadtrees](https://en.wikipedia.org/wiki/Quadtree) are a useful data\nstructure for sparse datasets where the location/position of the data is\nimportant. They're especially good for spatial indexing & image processing.\n\nAn actual visualization of a `quads.QuadTree`:\n\n![quadtree_viz](docs/images/quadtree_visualization.png)\n\n\n## Usage\n\nFull documentation at https://quads.readthedocs.io/en/latest/\n\n```python\n>>> import quads\n>>> tree = quads.QuadTree(\n...     (0, 0),  # The center point\n...     10,  # The width\n...     10,  # The height\n... )\n\n# You can choose to simply represent points that exist.\n>>> tree.insert((1, 2))\nTrue\n# ...or include extra data at those points.\n>>> tree.insert(quads.Point(4, -3, data=\"Samus\"))\nTrue\n\n# You can search for a given point. It returns the point if found...\n>>> tree.find((1, 2))\nPoint(1, 2)\n\n# Or `None` if there's no match.\n>>> tree.find((4, -4))\nNone\n\n# You can also find all the points within a given region.\n>>> bb = quads.BoundingBox(min_x=-1, min_y=-2, max_x=2, max_y=2)\n>>> tree.within_bb(bb)\n[Point(1, 2)]\n\n# You can also search to find the nearest neighbors of a point, even\n# if that point doesn't have data within the quadtree.\n>>> tree.nearest_neighbors((0, 1), count=2)\n[\n    Point(1, 2),\n    Point(4, -4),\n]\n\n# And if you have `matplotlib` installed (not required!), you can visualize\n# the tree.\n>>> quads.visualize(tree)\n```\n\n\n## Installation\n\n```\n$ pip install quads\n```\n\n\n## Requirements\n\n* Python 3.7+ (untested on older versions but may work)\n\n\n## Running Tests\n\n```\n$ git clone https://github.com/toastdriven/quads.git\n$ cd quads\n$ poetry install\n$ poetry shell\n\n# Just the tests.\n$ pytest .\n\n# With coverage.\n$ pytest -s --cov=quads .\n# And with pretty reports.\n$ pytest -s --cov=quads . && coverage html\n```\n\n\n## License\n\nNew BSD\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "A pure Python Quadtree implementation.",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/toastdriven/quads",
        "Repository": "https://github.com/toastdriven/quads"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0a18053514fdacc17ac4439496e44ccc99547e1672afce1536a2a8e84aacf5c2",
                "md5": "808d7c3c9d1c350fa04f2cf981b28a2a",
                "sha256": "4f2a05381f07fdf6d61352b0893819b2c52ae2286211c74bd9639a28d6424540"
            },
            "downloads": -1,
            "filename": "quads-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "808d7c3c9d1c350fa04f2cf981b28a2a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 9413,
            "upload_time": "2020-07-22T21:15:04",
            "upload_time_iso_8601": "2020-07-22T21:15:04.962101Z",
            "url": "https://files.pythonhosted.org/packages/0a/18/053514fdacc17ac4439496e44ccc99547e1672afce1536a2a8e84aacf5c2/quads-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "74c7257b7c30a7483e7cc699d0faf1695a04d3251f955789339a8d8f50c74008",
                "md5": "a4b4379fadbddd3e8bcaae1688e79528",
                "sha256": "59c1d86e551a734ea83c61c185c84873cf604b54bbacdfdbce831067715ecc7e"
            },
            "downloads": -1,
            "filename": "quads-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a4b4379fadbddd3e8bcaae1688e79528",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 9639,
            "upload_time": "2020-07-22T21:15:06",
            "upload_time_iso_8601": "2020-07-22T21:15:06.148963Z",
            "url": "https://files.pythonhosted.org/packages/74/c7/257b7c30a7483e7cc699d0faf1695a04d3251f955789339a8d8f50c74008/quads-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-07-22 21:15:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "toastdriven",
    "github_project": "quads",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "quads"
}
        
Elapsed time: 0.10617s