Skip to main content

A library for managing hierarchical numerical data structures

Project description

fractal-forest

fractal-forest is a Python library designed for efficient management and analysis of hierarchical numerical data structures. It supports recursive tree structures where each node contains a tuple of an integer and a generic value. The library can be optimized for real-time distributed processing and OLAP compatibility.

Features

  • Recursive tree structures with multiple children per node
  • Node values as tuples: (int, Any) for numerical aggregation and associated data
  • Automated tree creation and child addition
  • Integrity checks with automatic propagation of updates to parent and child nodes
  • Designed for hierarchical structured data such as:
    • Financial data (e.g., budgeting, accounting hierarchies)
    • Inventory systems (e.g., product categories, stock levels)
    • Organizational charts
    • Nested project management tasks
    • Any domain requiring structured aggregation and integrity validation

Installation

pip install fractal-forest

Usage

# usage_example.py
from fractal_forest import Fractal

# Create the root fractal
root = Fractal((10, "root"))

# Create child fractals
child1 = Fractal((5, "child1"))
child2 = Fractal((7, "child2"))

# Add children to root
root.add_child(child1)
root.add_child(child2)

# Print the tree structure after initial addition
print("Initial tree structure:")
root.print_tree()

# Access the updated value at root
print("Root value after aggregation:", root.value)  # Output will be (12, 'root') after aggregation

# Now update the value of child1, which triggers an update in the parent (root)
child1.update_value(6)  # New value of child1 is now 6 instead of 5

# Print the tree structure after update
print("\nTree structure after child1 update:")
root.print_tree()

# Access the updated value at root after update
print("Root value after child1 update:", root.value)  # The root value will reflect the change

# Now, simulate updating the value of a non-leaf (root), which triggers the creation of a new child to handle the difference
root.update_value(30)  # This will change the value of the root from 12 to 30

# Print the tree structure after the new child is created
print("\nTree structure after root value update:")
root.print_tree()

# Final root value after the update
print("Root value after manual update:", root.value)

License

MIT License

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

fractal_forest-0.2.0.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

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

fractal_forest-0.2.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file fractal_forest-0.2.0.tar.gz.

File metadata

  • Download URL: fractal_forest-0.2.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.1

File hashes

Hashes for fractal_forest-0.2.0.tar.gz
Algorithm Hash digest
SHA256 034e2bc202c7c5dd7ee5c426daa18bf26ff15ee5e578f6dd901ef1877b3042bb
MD5 8435f7ff46b3cd3e43d5dc2de6417738
BLAKE2b-256 360b5838ab5d243d4469e3d724fa0dca1d7b808d65f549145b8718af07624c9f

See more details on using hashes here.

File details

Details for the file fractal_forest-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: fractal_forest-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.1

File hashes

Hashes for fractal_forest-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9eb5542c5f4326073995ea273c17d91289dcdd22f335733531edcecb2da74794
MD5 9009710423e28dbbcd773e689af8a964
BLAKE2b-256 21b943967ded03589fd812937039d54c50f39797e1f22178aa3a69035aec9375

See more details on using hashes here.

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