Skip to main content

No project description provided

Project description

RetailTree

RetailTree is a Python library designed for efficient management and querying of spatial data utilizing a tree-based data structure. Specifically, RetailTree employs a VP (Vantage Point) tree for optimized spatial data management.

Key Features

  • Nearest Neighbor Search: RetailTree enables finding the nearest neighbors in 2D space.
  • Tree-Based Structure: Utilizes a VP tree for optimized spatial data management.
  • Top, Right, Left, and Bottom Annotations: Supports retrieval of annotations based on their relative positions.
  • Annotations within Angle Range: Provides functionality to retrieve annotations within a specified angle range relative to a reference point.

Installation

You can install retailTree via pip:

pip install retailtree

Usage

Import necessary modules and functions

# Imports
from retailtree import RetailTree, Annotation
from retailtree.utils.dist_func import manhattan, euclidean
import json

Sample Usage 1: Creating Annotations with Annotation Class using a sample JSON file

# Define the path to the JSON file containing annotations
file_path = './tests/test_data/test_data.json'

# Open and load the JSON file
with open(file_path, 'r') as file:
    annotations = json.load(file)

# Initialize a RetailTree object
rt = RetailTree()

# Iterate over the loaded annotations and create Annotation objects
for ann in annotations:
    # Create an Annotation object with the required properties
    ann_obj = Annotation(id=ann['id'], x_min=ann['x_min'], y_min=ann['y_min'], x_max=ann['x_max'], y_max=ann['y_max'])
    # Add the created Annotation object to the RetailTree
    rt.add_annotation(ann_obj)

OR

Sample Usage 2: Creating Annotations with Annotation Class

# Create annotation object
ann1 = Annotation(id=1, x_min=2, y_min=1, x_max=3, y_max=2)
ann2 = Annotation(id=2, x_min=1, y_min=2, x_max=2, y_max=3)
ann3 = Annotation(id=3, x_min=2, y_min=2, x_max=3, y_max=3)
ann4 = Annotation(id=4, x_min=3, y_min=2, x_max=4, y_max=3)
ann5 = Annotation(id=5, x_min=2, y_min=3, x_max=3, y_max=4)
annotations = [ann1, ann2, ann3, ann4, ann5]

# Create retailtree object
rt = RetailTree()

# Adding annotations to retailtree
for ann in annotations:
  rt.add_annotation(ann)

Building the Tree and Querying

Building the Tree

# Build the retail tree structure using the euclidean distance function
rt.build_tree(dist_func=euclidean)

Querying the Tree

# Retrieve and print annotations within a radius.
print(rt.neighbors(id=3, radius=1))

# Retrieve and print the Top, Bottom, Left, and Right neighboring annotations.
print(rt.TBLR(id=3, radius=1, overlap=0.5))

# Retrieve and print neighboring annotations of the annotation.
print(rt.neighbors_wa(id=3, radius=2, amin=0, amax=180))

# Retrieve and print the coordinates of the annotation.
print(rt.get(id=3).get_coords())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

retailtree-1.3.3.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

retailtree-1.3.3-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file retailtree-1.3.3.tar.gz.

File metadata

  • Download URL: retailtree-1.3.3.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for retailtree-1.3.3.tar.gz
Algorithm Hash digest
SHA256 30ad76a6002ed683361abf93b5cfb0d0466490b7311afc08de0a1d77f8e735d3
MD5 ac296e159ee365970e88ece8897b426d
BLAKE2b-256 35ee800f5590350f39c067b2f45f18d309a8b4e1dd3b33c05ebf4d2049185f31

See more details on using hashes here.

Provenance

The following attestation bundles were made for retailtree-1.3.3.tar.gz:

Publisher: workflow.yml on ParallelDots/RetailTree

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file retailtree-1.3.3-py3-none-any.whl.

File metadata

  • Download URL: retailtree-1.3.3-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for retailtree-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bcea44a7a6003507196eca3d787bed46af740604bed22830e65ad7c4a121baa5
MD5 e73aecec4134bd2726cf8a5fe27f460c
BLAKE2b-256 801ea4322ce280d09eb720b45eb5cd82d10a2ad1efc21f8b56b06fae8298ad78

See more details on using hashes here.

Provenance

The following attestation bundles were made for retailtree-1.3.3-py3-none-any.whl:

Publisher: workflow.yml on ParallelDots/RetailTree

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page