Tree is a library for working with nested data structures.
Project Links
Meta
Author: DeepMind
Requires Python: >=3.10
Classifiers
Development Status
- 4 - Beta
Intended Audience
- Developers
- Science/Research
License
- OSI Approved :: Apache Software License
Programming Language
- Python :: 3.10
- Python :: 3.11
- Python :: 3.12
- Python :: 3.13
Topic
- Scientific/Engineering :: Mathematics
- Software Development :: Libraries
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
From PyPI:
$ pip install dm-tree
Directly from github using pip:
$ pip install git+git://github.com/deepmind/tree.git
Build from source:
$ python setup.py install
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.
Jan 30, 2025
0.1.9
Dec 18, 2022
0.1.8
Apr 11, 2022
0.1.7
Apr 12, 2021
0.1.6
May 01, 2020
0.1.5
Mar 30, 2020
0.1.4
Jan 29, 2020
0.1.2
Nov 11, 2019
0.1.1
Nov 05, 2019
0.1.0
Wheel compatibility matrix
Files in release
Extras:
None
Dependencies:
(>=0.6.1)
absl-py
(>=18.2.0)
attrs
(>=1.21)
numpy
(>=1.11.2)
wrapt
(>=1.21.2)
numpy
(>=1.23.3)
numpy
(>=1.26.0)
numpy
(>=2.1.0)
numpy