Python

pytreeclass

Latest version: v0.2.2

PyUp actively tracks 511,114 Python packages for vulnerabilities to keep your Python environments secure.

Scan your dependencies

Page 1 of 6

0.2.2

- Add id entry for standard python datatypes and treeclass wrapped classes in the metadata path.

python
import pytreeclass as pytc
tree = [1, [2, [3]]]
traces, _ = zip(*pytc.tree_leaves_with_trace(tree))
print(pytc.tree_repr([trace[3] for trace in traces]))
[
({id:4843302976}, {id:4307173616}),
({id:4843302976}, {id:4843303936}, {id:4307173648}),
({id:4843302976}, {id:4843303936}, {id:4843297408}, {id:4307173680})
]

- `is_tree_equal(*trees)` now accepts arbitrary number of pytrees.
- `FrozenWrapper` is private.
- [internal] merge new wrapper into init wrapper

**Full Changelog**: https://github.com/ASEM000/PyTreeClass/compare/v0.2.1...v0.2.2

0.2.1

- use `dataclass_transform` for better typing/autocomplete
- use one time validation on user-defined traces .

**Full Changelog**: https://github.com/ASEM000/PyTreeClass/compare/v0.2.0...v0.2.1

0.2

**Full Changelog**: https://github.com/ASEM000/PyTreeClass/compare/v0.1.13...0.2.0b13

0.2.0

🔥 Big update

**Mostly rewritten from scratch.**

Changes:
- Drop the standard library `dataclasses.dataclass` for faulty logic treating jax.numpy as mutable object from python 3.11 see: 33
- Implements a simpler `dataclass`-like version that additionally implements:
- `pos_only` to mark the argument as positional only
- `callbacks` to apply a set of functions (e.g., validators/converters) on input see: 37

- Drop metadata-based approach for marking fields static. move to a transparent wrapper approach for faster, simpler, and flexible marking of leaves static see [here](https://pytreeclass.readthedocs.io/en/latest/notebooks/freezing.html)
- `tree_summary`, `tree_diagram`, `tree_str`, and `tree_repr` can now work on any `pytree`(including registered pytrees) out of the box [see](https://pytreeclass.readthedocs.io/en/latest/notebooks/getting_started.html#)
- Remove `tree.summary()` in favor of `pytc.tree_summary(model)`
- Remove `tree.tree_diagram()` in favor of `pytc.tree_diagram(model)`
- Remove `tree.tree_box()`
- Add `tree_{repr,str,diagram,summary,mermaid}(..., depth)` to control cutoff depth condition for visualization.
- Make math operations on leaves opt-in feature via `treeckass(... , leafwise=True)`
- Drop filtering by `metadata` , `types`, and `name`. Instead, use `tree_map_with_trace` to access leaves' name,type,index, and metadata at each level along their path. see 35
- Add `bcmap` : a function transformation for automatic broadcasting. see readme More section.
- using `bcmap` with `treeclass(... , leafwise=True)` achieves a data model that enables applying `numpy` functions like `numpy.where` on arbitrary PyTrees without the need for `tree_map`.
- Faster flatten/unflatten see benchmarks comparison with flax/equinox.


Internally, unifying indexing and viz tools by implementing custom jax-like registry to record names, types, indices, and metadata rules for common python data structures and `treeclass` wrapped class. You can check the readme More section for registering custom classes to work fully with the viz/indexing tools similar to Jax registration process.

0.2.0b13

0.1.13

What's Changed
* Enable regex str comparison by ASEM000 in https://github.com/ASEM000/PyTreeClass/pull/31


**Full Changelog**: https://github.com/ASEM000/PyTreeClass/compare/v0.1.12...v0.1.13

Page 1 of 6