ASEM000/PyTreeClass: v0.2.0
Description
Mostly rewritten from scratch.
Changes:- Drop the standard library
dataclasses.dataclassfor faulty logic treating jax.numpy as mutable object from python 3.11 see: #33 Implements a simpler
dataclass-like version that additionally implements:pos_onlyto mark the argument as positional onlycallbacksto 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
tree_summary,tree_diagram,tree_str, andtree_reprcan now work on anypytree(including registered pytrees) out of the box see- Remove
tree.summary()in favor ofpytc.tree_summary(model) - Remove
tree.tree_diagram()in favor ofpytc.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, andname. Instead, usetree_map_with_traceto 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
bcmapwithtreeclass(... , leafwise=True)achieves a data model that enables applyingnumpyfunctions likenumpy.whereon arbitrary PyTrees without the need fortree_map.
- using
- 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.
Files
ASEM000/PyTreeClass-v0.2.0.zip
Files
(232.8 kB)
| Name | Size | Download all |
|---|---|---|
|
md5:15c2d9e7d9772b049df7f519652819fe
|
232.8 kB | Preview Download |
Additional details
Related works
- Is supplement to
- https://github.com/ASEM000/PyTreeClass/tree/v0.2.0 (URL)