Skip to content

Commit

Permalink
[AtIndexer] make string key points to regex by default, remove BaseKey
Browse files Browse the repository at this point in the history
  • Loading branch information
ASEM000 committed Mar 20, 2024
1 parent 3f92f91 commit 9f26b58
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 242 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@

- `tree_{mask,unmask}` now accepts only callable `cond` argument.
- Rename `is_frozen` to `is_masked`
- frozen could mean non-trainable array, however the masking is not only for arrays but also for other types that will be hidden from jax transformations.
- frozen could mean non-trainable array, however the masking is not only for arrays but also for other types that will be hidden across jax transformations.
- Remove `re.compile(pattern)` to match `re.Pattern` in `where` argument in `AtIndexer`, instead use string `pattern` directly.

## V0.11.3

Expand Down
7 changes: 2 additions & 5 deletions docs/API/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
.. autoclass:: TreeClass
:members:
at
.. autoclass:: AtIndexer
.. autoclass:: at
:members:
get,
set,
Expand All @@ -16,10 +16,7 @@
reduce,
pluck,

.. autoclass:: at
.. autoclass:: BaseKey
:members:
__eq__
.. autoclass:: AtIndexer
.. autofunction:: autoinit
.. autofunction:: leafwise
.. autofunction:: field
Expand Down
3 changes: 1 addition & 2 deletions sepes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from sepes._src.backend import backend_context
from sepes._src.code_build import autoinit, field, fields
from sepes._src.tree_base import TreeClass
from sepes._src.tree_index import AtIndexer, BaseKey, at
from sepes._src.tree_index import AtIndexer, at
from sepes._src.tree_mask import (
is_masked,
is_nondiff,
Expand Down Expand Up @@ -53,7 +53,6 @@
# indexing utils
"AtIndexer",
"at",
"BaseKey",
# tree utils
"bcmap",
"leafwise",
Expand Down
2 changes: 0 additions & 2 deletions sepes/_src/tree_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ def at(self) -> AtIndexer[Self]:
- ``int`` for positional indexing for sequences.
- ``...`` to select all leaves.
- a boolean mask of the same structure as the tree
- ``re.Pattern`` to index all keys matching a regex pattern.
- an instance of ``BaseKey`` with custom logic to index a pytree.
- a tuple of the above types to index multiple keys at same level.
Example:
Expand Down
Loading

0 comments on commit 9f26b58

Please sign in to comment.