Skip to main content

Tree is a library for working with nested data structures.

Project description

Tree

tree is a library for working with nested data structures. In a way, tree generalizes the builtin map function which only supports flat sequences, and allows to apply a function to each "leaf" preserving the overall structure.

>>> import tree
>>> structure = [[1], [[[2, 3]]], [4]]
>>> tree.flatten(structure)
[1, 2, 3, 4]
>>> tree.map_structure(lambda v: v**2, structure)
[[1], [[[4, 9]]], [16]]

tree is backed by an optimized C++ implementation suitable for use in demanding applications, such as machine learning models.

Installation

Install tree by running:

$ pip install dm-tree

Support

If you are having issues, please let us know by filing an issue on our issue tracker.

License

The project is licensed under the Apache 2.0 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

dm-tree-0.1.6.tar.gz (33.6 kB view hashes)

Uploaded Source

Built Distributions

dm_tree-0.1.6-cp310-cp310-win_amd64.whl (91.0 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

dm_tree-0.1.6-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (142.5 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.12+ x86-64

dm_tree-0.1.6-cp310-cp310-macosx_11_0_arm64.whl (104.9 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

dm_tree-0.1.6-cp310-cp310-macosx_10_9_x86_64.whl (109.3 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

dm_tree-0.1.6-cp310-cp310-macosx_10_9_universal2.whl (156.4 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)

dm_tree-0.1.6-cp39-cp39-win_amd64.whl (74.9 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

dm_tree-0.1.6-cp39-cp39-manylinux_2_24_x86_64.whl (94.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.24+ x86-64

dm_tree-0.1.6-cp39-cp39-manylinux2014_x86_64.whl (116.4 kB view hashes)

Uploaded CPython 3.9

dm_tree-0.1.6-cp39-cp39-macosx_11_0_arm64.whl (105.0 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

dm_tree-0.1.6-cp39-cp39-macosx_10_14_x86_64.whl (95.3 kB view hashes)

Uploaded CPython 3.9 macOS 10.14+ x86-64

dm_tree-0.1.6-cp39-cp39-macosx_10_9_universal2.whl (156.7 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

dm_tree-0.1.6-cp38-cp38-win_amd64.whl (75.1 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

dm_tree-0.1.6-cp38-cp38-manylinux_2_24_x86_64.whl (94.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.24+ x86-64

dm_tree-0.1.6-cp38-cp38-manylinux2014_x86_64.whl (116.5 kB view hashes)

Uploaded CPython 3.8

dm_tree-0.1.6-cp38-cp38-macosx_11_0_arm64.whl (105.1 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

dm_tree-0.1.6-cp38-cp38-macosx_10_14_x86_64.whl (95.4 kB view hashes)

Uploaded CPython 3.8 macOS 10.14+ x86-64

dm_tree-0.1.6-cp38-cp38-macosx_10_9_universal2.whl (156.7 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)

dm_tree-0.1.6-cp37-cp37m-win_amd64.whl (75.4 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

dm_tree-0.1.6-cp37-cp37m-manylinux_2_24_x86_64.whl (94.0 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.24+ x86-64

dm_tree-0.1.6-cp37-cp37m-manylinux2014_x86_64.whl (115.7 kB view hashes)

Uploaded CPython 3.7m

dm_tree-0.1.6-cp37-cp37m-macosx_10_14_x86_64.whl (94.7 kB view hashes)

Uploaded CPython 3.7m macOS 10.14+ x86-64

dm_tree-0.1.6-cp36-cp36m-win_amd64.whl (75.4 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

dm_tree-0.1.6-cp36-cp36m-manylinux_2_24_x86_64.whl (93.9 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.24+ x86-64

dm_tree-0.1.6-cp36-cp36m-manylinux2014_x86_64.whl (115.6 kB view hashes)

Uploaded CPython 3.6m

dm_tree-0.1.6-cp36-cp36m-macosx_10_14_x86_64.whl (94.7 kB view hashes)

Uploaded CPython 3.6m macOS 10.14+ x86-64

Supported by

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