dm-tree 0.1.9


pip install dm-tree

  Latest version

Released: Jan 30, 2025

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.

Wheel compatibility matrix

Platform CPython 3.10 CPython 3.11 CPython 3.12 CPython 3.13 CPython (additional flags: t) 3.13
macosx_10_13_universal2
macosx_10_9_universal2
manylinux2014_aarch64
manylinux2014_x86_64
manylinux_2_17_aarch64
manylinux_2_17_x86_64
win_amd64

Files in release

Extras: None
Dependencies:
absl-py (>=0.6.1)
attrs (>=18.2.0)
numpy (>=1.21)
wrapt (>=1.11.2)
numpy (>=1.21.2)
numpy (>=1.23.3)
numpy (>=1.26.0)
numpy (>=2.1.0)