Skip to main content

locus

Github Actions Documentation Codecov License PyPI

In what follows python is an alias for python3.10 or pypy3.10 or any later version (python3.11, pypy3.11 and so on).

Installation

Prerequisites

Install the latest pip & setuptools packages versions

python -m pip install --upgrade pip setuptools

User

Download and install the latest stable version from PyPI repository

python -m pip install --upgrade locus

Developer

Download the latest version from GitHub repository

git clone https://github.com/lycantropos/locus.git
cd locus

Install

python -m pip install -e '.'

Usage

>>> import math
>>> from fractions import Fraction
>>> from ground.context import Context
>>> context = Context(coordinate_factory=Fraction, sqrt=math.sqrt)
>>> Box, Point, Segment = (
...     context.box_cls,
...     context.point_cls,
...     context.segment_cls
... )
>>> from locus import kd
>>> points = list(map(Point, range(-10, 11), range(0, 20)))
>>> kd_tree = kd.Tree(points, context=context)
>>> kd_tree.nearest_index(Point(0, 0)) == 5
True
>>> kd_tree.nearest_point(Point(0, 0)) == Point(-5, 5)
True
>>> kd_tree.n_nearest_indices(2, Point(0, 0)) == [6, 5]
True
>>> kd_tree.n_nearest_points(2, Point(0, 0)) == [Point(-4, 6), Point(-5, 5)]
True
>>> kd_tree.find_box_indices(Box(-1, 1, 0, 10)) == [9, 10]
True
>>> kd_tree.find_box_points(Box(-1, 1, 0, 10)) == [Point(-1, 9), Point(0, 10)]
True
>>> from locus import r
>>> boxes = list(
...     map(Box, range(-10, 11), range(0, 20), range(-20, 0), range(-10, 11))
... )
>>> r_tree = r.Tree(boxes, context=context)
>>> r_tree.nearest_index(Point(0, 0)) == 10
True
>>> r_tree.nearest_box(Point(0, 0)) == Box(0, 10, -10, 0)
True
>>> r_tree.n_nearest_indices(2, Point(0, 0)) == [10, 11]
True
>>> r_tree.n_nearest_boxes(2, Point(0, 0)) == [
...     Box(0, 10, -10, 0), Box(1, 11, -9, 1)
... ]
True
>>> r_tree.find_subsets_indices(Box(0, 10, -10, 10)) == [10]
True
>>> r_tree.find_subsets(Box(0, 10, -10, 10)) == [Box(0, 10, -10, 0)]
True
>>> r_tree.find_supersets_indices(Box(0, 10, -10, 0)) == [10]
True
>>> r_tree.find_supersets(Box(0, 10, -10, 0)) == [Box(0, 10, -10, 0)]
True

Development

Bumping version

Prerequisites

Install bump-my-version.

Release

Choose which version number category to bump following semver specification.

Test bumping version

bump-my-version bump --dry-run --verbose $CATEGORY

where $CATEGORY is the target version number category name, possible values are patch/minor/major.

Bump version

bump-my-version bump --verbose $CATEGORY

This will set version to major.minor.patch.

Running tests

Plain

Install with dependencies

python -m pip install -e '.[tests]'

Run

pytest

Docker container

Run

  • with CPython

    docker-compose --file docker-compose.cpython.yml up
    
  • with PyPy

    docker-compose --file docker-compose.pypy.yml up
    

Bash script

Run

  • with CPython

    ./run-tests.sh
    

    or

    ./run-tests.sh cpython
    
  • with PyPy

    ./run-tests.sh pypy
    

PowerShell script

Run

  • with CPython

    .\run-tests.ps1
    

    or

    .\run-tests.ps1 cpython
    
  • with PyPy

    .\run-tests.ps1 pypy
    

Metadata

Release files for locus 11.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for locus 11.0.0
File Size Uploaded
locus-11.0.0.tar.gz 16.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for locus 11.0.0
File Interpreter ABI Platform
locus-11.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 34.8 kB

Release files / locus-11.0.0.tar.gz

Download URL locus-11.0.0.tar.gz
Size 16.1 kB
Tags Source
SHA-256 checksum
How to use checksums
18c5ddead08b6576abeeb1eba49111cfdfcf2f9c84f056c7c3dab657334266ca
BLAKE2b-256 checksum
How to use checksums
27bb2ff19d2365bd7efa4b882e9686dd0f4ef6ad663af32446a2b545bb29928c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / locus-11.0.0-py3-none-any.whl

Download URL locus-11.0.0-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7108293bdc633cd07b038b717966eb074c14fc69d7bc9b96e8ceab59b67d7fcb
BLAKE2b-256 checksum
How to use checksums
727381eb4bdce630dbaff892c5e4f74290a87e1f553f612150902a679bc57e91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

11.0.0 This release

2 release files

10.1.0

2 release files

10.0.0

2 release files

9.0.0

2 release files

8.2.0

2 release files

8.1.0

2 release files

8.0.0

2 release files

7.0.0

2 release files

6.0.0

2 release files

5.1.0

2 release files

5.0.0

2 release files

4.0.0

2 release files

3.0.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page