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.0.tar.gz (31.1 kB view hashes)

Uploaded Source

Built Distributions

dm_tree-0.1.0-cp37-cp37m-manylinux2010_x86_64.whl (89.7 kB view hashes)

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

dm_tree-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl (83.2 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

dm_tree-0.1.0-cp36-cp36m-manylinux2010_x86_64.whl (89.7 kB view hashes)

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

dm_tree-0.1.0-cp36-cp36m-macosx_10_9_x86_64.whl (83.1 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

dm_tree-0.1.0-cp35-cp35m-manylinux2010_x86_64.whl (89.7 kB view hashes)

Uploaded CPython 3.5m manylinux: glibc 2.12+ x86-64

dm_tree-0.1.0-cp35-cp35m-macosx_10_6_intel.whl (83.1 kB view hashes)

Uploaded CPython 3.5m macOS 10.6+ intel

dm_tree-0.1.0-cp27-cp27mu-manylinux2010_x86_64.whl (90.2 kB view hashes)

Uploaded CPython 2.7mu manylinux: glibc 2.12+ x86-64

dm_tree-0.1.0-cp27-cp27m-macosx_10_9_x86_64.whl (83.7 kB view hashes)

Uploaded CPython 2.7m macOS 10.9+ 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